← Back to Views & Indexes
Question 64
Honour Roll From a View
Honour Roll From a View
Create a view calledstudent_averageswith one row per student who has at least onecompletedenrollment: columnsstudent_id,completed(how many completed enrollments) andavg_grade(the averagegradeover those, rounded to 1 decimal). Then, in the same script, query the view: join it tostudentsand returnfirst_name,last_name,completedandavg_gradefor everyone whoseavg_gradeis 85 or more, sorted byavg_gradedescending, thenlast_name. Dropped and in-progress enrollments must not count.
Expected result:
Table student_averages ✓ student_id INTEGER ✓ completed (no type) ✓ avg_grade (no type) +------------+-----------+-----------+-----------+ | first_name | last_name | completed | avg_grade | +------------+-----------+-----------+-----------+ | Evelyn | Park | 2 | 96 | | Sophia | Rossi | 2 | 92.5 | | Grace | Lee | 3 | 92.3 | | Emily | Zhang | 3 | 91.3 | | Ava | Patel | 2 | 90 | | Charlotte | Dubois | 3 | 87.7 | | Mia | Haddad | 2 | 86.5 | | Scarlett | Johnson | 2 | 86 | +------------+-----------+-----------+-----------+ 8 rows
Hints4 available
Sign in to use hintsTopics:
Views & Indexes
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.