Am i on the right path to figuring out this CASE statement

Viewed 17

Create a query that returns the alphabetized first letter of the customer's last name and the count of active and inactive customers. Limit the results to only those first letters that occur in the last_name column of the customer table.

Label the columns as follows:

starts_with is the first column and the first letter of the customer's last_name. active_count is the second column and the count of active customers (as defined in the textbook examples of Chapter 11). inactive_count is the third column and the count of inactive customers (as defined in the textbook examples of Chapter 11). The output should look like the following: The image shows the table This is using the sakila database and using CASE

so far i have gotten this far and im not sure i am doing the right thing at all. I have been working on this for 3 hours and im a little overwhelmed

SELECT DISTINCT LEFT(last_name,1) FROM customer SUM(CASE WHEN last_name = 'A' THEN 1 END) SUM(CASE WHEN last_name = 'B' THEN 1 END)

0 Answers
Related