Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 3v0k4/640caa922a1ec46270345803d2f49450 to your computer and use it in GitHub Desktop.
Save 3v0k4/640caa922a1ec46270345803d2f49450 to your computer and use it in GitHub Desktop.
=> SELECT films.id, films.title, films.genre, count(*) as number_of_reviews FROM films LEFT JOIN reviews ON films.id = reviews.film_id GROUP BY films.id;
id | title | genre | number_of_reviews
----+-------------------+----------+-------------------
3 | Arrival | scifi | 1
1 | Blade Runner 2049 | thriller | 3
2 | Inception | thriller | 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment