php - MySQL: Group By & Count Multiple Fields -


If I have a field, say, project_id where I want to count events, I will do something like this:

  Select project_id, count as counting from project group by tbl group (project_id), count desc << code>  

what would happen if I Count the incidents of a combination of two fields in the same table, i.e. calculate the number of rows where the projections The combination of T_aidi and Sewa_aidi unique?

So, so I have records in my table:

  Project_id service_id 1 1 2 1 2 1 2 1 2 1 2 1 3 1 4 1 4 1 4 I The result of your query is something like: project_id service_id count 1 1 1 1 2 4 1 3 1 1 4 3    

>
  select  service_id  to  group  from the tbl group as project_id, service_id, count (*) and  Select    

> list. Should do this.

Edit -

According to the comment from @Rajah It seems that for your expected output, you Project_ID ACH, Service_ID ASC

Comments