CASE Statement organised with ORDER BY

Hi hello,
On the purpose of the exercise on LEARN SQL, query xercise about eh New York Restaurants, the code for the final exercise is as follows:

SELECT name,
CASE
WHEN review > 4.5 THEN ‘Extraordinary’
WHEN review > 4 THEN ‘Excellent’
WHEN review > 3 THEN ‘Good’
WHEN review > 2 THEN ‘Fair’
ELSE ‘Poor’
END AS ‘Review’
FROM nomnom;

Is there a way to have the query organized by the review in groups according to he CASE statement? Currently all reviews are mixed not following any order or grouping.
Thanks.

Did you try:

SELECT
FROM
ORDER BY review,
CASE WHEN….
END;

?

Don’t be afraid to mix up your code to see what works and what doesn’t too.

1 Like

GREAT thanks. I had try and the combination of it mixing the code. Thanks for the tip.

1 Like