I have searched for the issue but could not have a working solution.
I have 3 tables: User, Post, Comments.
select u.id user
, p.id post
, c.id comm
from USer u
join Post p
on u.id = p.user_id
join Comments c
on p.id = c.post_id;
This gives me an output with 3 columns that relates a user with the posts they have and the comments received on each.
The o/p is like:
user post comm
1 1 4
1 1 5
1 1 7
1 1 8
2 5 11
2 5 12
2 7 13
I wanted to find the user with the maximum number of overall comm. For this the GROUP BY
on user is not working. What could be an alternative for the task?