The hypothetical table contains the following coloumns:
id integer,
name char(6),
status integer
And has the following data:
id id2 type
--- ----- ----
01 Adam 1
02 Bob 1
03 Adam 2
04 Caymen 1
05 Ahmed 1
06 Basel 1
07 Ahmed 2
08 Bob 2
09 Ahmed 2
10 Mike 1
Thus, it basically tracks the progress of the state for different users.
I want to group by the number of statuses. In other words, I want to know how many users have only 1 status, how many have 2 status, how many have 3 status, etc.
The expected result will be something like this:
num_of_statuses count
--------------- -----
1 3
2 2
3 1
I tried, but cannot find a solution. Any syntax is fine. SQL / MySQL / DB2 / Oracle.
Isaac source
share