Created
November 2, 2017 14:46
-
-
Save mattm/df884c0682134c5048532fa667502e2f to your computer and use it in GitHub Desktop.
This file contains 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
SELECT users.user_id, COUNT(post_id) AS post_count | |
FROM users | |
LEFT JOIN posts ON posts.user_id = users.user_id | |
GROUP BY 1 | |
+---------+------------+ | |
| user_id | post_count | | |
+---------+------------+ | |
| 1 | 3 | | |
| 2 | 2 | | |
| 3 | 0 | | |
+---------+------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
correct one, it's the same case i was trying to resolve. Thanks