Every Instructor's Course Load
mediumQuestion 101For every instructor, count the courses they teach. Return first_name, last_name and courses (the count). Yuki Tanaka teaches nothing yet and must still appear with 0. Sort by courses from most to fewest, then by last_name.
Expected result
+------------+-----------+---------+ | first_name | last_name | courses | +------------+-----------+---------+ | Grace | Okafor | 2 | | Daniel | Reyes | 2 | | Helen | Brooks | 1 | | Mei | Chen | 1 | | Amara | Diallo | 1 | | Olivia | Grant | 1 | | Marcus | Lindqvist | 1 | | Rafael | Moreno | 1 | | Priya | Natarajan | 1 | | Tomasz | Nowak | 1 | +------------+-----------+---------+ (showing 10 of 12 rows)
Hints3 available
Sign in to use hintsTopics
Joins
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 under the question.