Table Schema
Inspect
Table
| Column | Type |
|---|---|
| playlist_id | integer |
| song_id | integer |
Find playlists with more than 5 songs.
Table Schema
| Column | Type |
|---|---|
| playlist_id | integer |
| song_id | integer |
Sample Data
| playlist_id | song_id |
|---|---|
| 1 | 101 |
| 1 | 102 |
| 1 | 103 |
| 1 | 104 |
| 1 | 105 |
| 1 | 106 |
| 2 | 201 |
| 2 | 202 |
| playlist_id |
|---|
| 1 |
SQL Editor
| playlist_id |
|---|
| 1 |
Hints
Solution
Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.
SELECT playlist_id FROM playlist_songs GROUP BY playlist_id HAVING COUNT(*) > 5;
Explanation
Read the expected output columns to determine the final grain.
Aggregate or rank the input rows to calculate the requested metric.
Filter, sort, and alias the final columns to match the output.
Related Questions