This is my first question on stackoverflow, welcome everybody.
I have a table:
id fk_user
1 1
2 1
3 3
4 2
5 3
And I would like to prepare an SQL query witch returns fk_user sorted by the number of occurrences in that table. For instance:
fk_user 1 occurs 3 times, so it will be first.
fk_user 2 occurs once, so it will be last.
fk_user 3 occurs twice, so it will be the second.
Result of that query should be:
fk_user
1
3
2
1 Answer