Created
December 1, 2021 04:55
-
-
Save silentsudo/efae82349ae885c6c25f2028340e6c46 to your computer and use it in GitHub Desktop.
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
SELECT f.id, u.email, | |
count(distinct l.id) as likes_count, | |
count(distinct c.id) as comments_count | |
FROM feeds f | |
INNER JOIN users u ON f.user_id = u.id | |
INNER JOIN likes l on l.feed_id = f.id | |
left join comments c on c.feed_id = f.id | |
WHERE u.id = 12055 | |
group by f.id order by comments_count asc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment