This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Part 1: Basic JOINs | |
| -- 1. List all album names with their artist names (use appropriate through table) | |
| SELECT | |
| al.name AS album_name, | |
| ar.name AS artist_name | |
| FROM | |
| albums al | |
| JOIN r_albums_artists raa ON raa.album_id = al.id | |
| JOIN artists ar ON ar.id = raa.artist_id | |
| ORDER BY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Part 1: Basic Queries | |
| -- 1. Find the 10 longest books (by pages) in the database | |
| select | |
| * | |
| from | |
| books | |
| where | |
| pages is not null | |
| order by | |
| pages desc |