Combine group by and count mysql

后端 未结 2 1629
轻奢々
轻奢々 2021-01-24 05:55

I need to find out all statuses in a table using group by:

SELECT status FROM table GROUP BY status

And then count the results found

         


        
相关标签:
2条回答
  • 2021-01-24 06:35

    Just group by status this will give you desired result

    select status, count(id) as COUNT FROM table GROUP BY status
    
    0 讨论(0)
  • 2021-01-24 06:42

    Use below query:

    SELECT status, count(id) as CNT FROM table GROUP BY status
    
    0 讨论(0)
提交回复
热议问题