How to count how many items for distinct items in mysql?
- by Vincent Duprez
Imagine a have a table with a column named status:
status
------
A
A
A
B
C
C
D
D
D
How can I count how many rows have A, how many rows have B etc?
this kind of output:
A |B |C |D |E
------------------
3 |1 |2 |3 |0
As for E = O , this will always be A,B,C,D and E
Output should be one row (thus 1 query).
When doing a distinct count (most returning answer on my searches, it does return how many different elements there are, 4 in this case...)