← Back to CTEs
Question 42
Honour Roll Through a CTE
Honour Roll Through a CTE
Write a CTE namedhonour_rollthat selectsfirst_name,last_nameandgpafor every student whosegpais 3.5 or higher, then select those three columns fromhonour_roll. Sort bygpadescending, thenlast_name. Students with a NULLgpafall out of the filter on their own.
Expected result:
+------------+-----------+------+ | first_name | last_name | gpa | +------------+-----------+------+ | Evelyn | Park | 3.98 | | Sophia | Rossi | 3.92 | | Grace | Lee | 3.88 | | Mia | Haddad | 3.8 | | Ava | Patel | 3.8 | | Emily | Zhang | 3.72 | | Charlotte | Dubois | 3.67 | | Scarlett | Johnson | 3.6 | | Harper | Singh | 3.55 | | Zoe | Campbell | 3.5 | +------------+-----------+------+ 10 rows
Hints3 available
Sign in to use hintsTopics:
CTEs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)
Results
Run your SQL to see every statement's output here, then how it compares with the expected answer.
Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.