Consider the following MySQL table:
user_id
-------
1
1
2
3
3
3
3
I would like an output of:
user_id cnt
-------------
1 2
2 1
3 4
I though this would make that happen, but it doesn’t:
SELECT user_id, COUNT(1) FROM table GROUP BY user_id
What am I doing wrong?
btw, there is also the curiosity:
Both will give you the output you want.