mysql - get count of all users for particular category and rank them -


How do I calculate each user's contribution / I'm looking for that particular category. The user in the table below is the category. I have contributed several times to the number of dog count / participated in the table given below and rank them.

Create table does not exist if TBA (id int (11) null auto_intermiment, user varchar (255), category int (255), primary key (id)); Value ('1', '1'), ('1', '2'), ('1', '3'), ('1', '1'), (TBA (user, category) Do '2', '1'), ('2', '1');

Like a response: search for the category where its '1'

  the user's rank calculation rank 1 1 2 1 2 1 2 2  

  SELECT USER, num to tblA WHERE as category, count (*) Category = 1 group by USER, number DESC by category order;  

demo :


Comments