0
Need help with ORDER BY + IN combination, I can't figure out how to solve this question
The marketing department wants to focus on the customers from North America first. Gets the ID, last name and country of all customers. Build the list by bringing up the customers living in Canada and in the USA first, and finally ordered them by ID. Tip: Use the IN expression in the ORDER BY clause. I tried: SELECT LastName, Country From Customers ORDER BY Country IN ('Canada', 'USA'), CustomerID ; It isn't working, I can't use WHERE cause it's supposed to list customers from all countries afterwards
3 Respuestas
+ 4
You wrote Country wrong.
You are not selecting ID.
Try this
SELECT CustomerID, LastName, Country From Customers ORDER BY FIELD(Country, "Canada," "USA"), CustomerID
0
thx but I checked, I miss typed here but not there and the condition of the task is to specifically us IN in the ORDER BY clause
ps I corrected the typo above, thx
0
figured it out! it needs DESC or ASC after the ORDER BY Country (....)
lol and now it works!