Skip to content

Instantly share code, notes, and snippets.

@mattm

mattm/join.sql

Created Nov 1, 2017
Embed
What would you like to do?
SELECT users.user_id, COUNT(*) AS post_count
FROM users
JOIN posts ON posts.user_id = users.user_id
GROUP BY 1
+---------+------------+
| user_id | post_count |
+---------+------------+
| 1 | 3 |
| 2 | 2 |
+---------+------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.