Current DB for update_log
ID CatName UserID
-----------------------------
1 book 2
2 book 2
3 book 1
4 car 1
5 car 2
6 car 3
7 car 1
8 house 2
9 house 1
10 house 1
What is the correct statement to count CatName and UserID then GROUP BY CatName and UserID
SELECT
CatName,
UserID,
COUNT(CatName) as CategoryName,
COUNT(UserID) as MostUser
FROM update_log
GROUP BY CatName
ORDER BY COUNT(CatName) DESC
I want the result should be like this
Category Name Most Posted by
-----------------------------
book 2
car 1
house 1
This should work, although I feel like there must be a better/more succinct way of doing this: