Reputation: 3
I need to create SQL Query:
List all customers who do not live in Illinois (IL), New York (NY), or California (CA). Sort them by Postal Code in an ascending order. In the result table, show customer name, state, and postal code.
My Query is
SELECT CUSTOMER_NAME, STATE, POSTAL_CODE
FROM CUSTOMER_T
WHERE STATE NOT IN ('CA', 'FL', 'NJ')
GROUP BY POSTAL_CODE
But it doesn't work.
Upvotes: 0
Views: 181
Reputation: 194
Try this:
SELECT CUSTOMER_NAME, STATE, POSTAL_CODE
FROM CUSTOMER_T
WHERE STATE NOT IN ('CA', 'FL', 'NJ')
Order BY POSTAL_CODE Asc
You don't need Group By Here. Replace Group By With Order By.
Upvotes: 1
Reputation: 11599
I think you are doing mistake
SELECT CUSTOMER_NAME, STATE, POSTAL_CODE
FROM CUSTOMER_T
WHERE STATE NOT IN ('CA', 'IL', 'NY')
^ ^
Order BY POSTAL_CODE Asc
^
Upvotes: 0