I have this request :
SELECT id_user
FROM posts
GROUP BY id_user
ORDER BY COUNT(*) DESC
…which will return the id_user, ordered by their number of occurrence in the posts table.
But along with the id_user information, I would like to keep track of the COUNT(*) and store it somewhere, but I have no idea how to do it.
Use:
The column alias in the example,
numPosts, can then be referenced in whatever you’re already using to get theid_usercolumn values.