Challenge: Custom Movie Ranking
Task
Swipe to start coding
Write a query that ranks movies using a custom rule. 'Action' movies with a box_office greater than or equal to 50000000 should come first. All other movies should follow, ordered by rating in descending order.
- Select all columns from the
moviestable. - Use
CASE WHENin theORDER BYclause to ensure 'Action' movies withbox_office>= 50000000 appear first. - For movies not meeting the above condition, order them by
ratingin descending order.
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 5
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4.17
Challenge: Custom Movie Ranking
Swipe to show menu
Task
Swipe to start coding
Write a query that ranks movies using a custom rule. 'Action' movies with a box_office greater than or equal to 50000000 should come first. All other movies should follow, ordered by rating in descending order.
- Select all columns from the
moviestable. - Use
CASE WHENin theORDER BYclause to ensure 'Action' movies withbox_office>= 50000000 appear first. - For movies not meeting the above condition, order them by
ratingin descending order.
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 5
single