SELECT COUNT(UNIQUE(column)) ?????
Posted: Fri Mar 06, 2009 11:51 am
This is maybe a little hard to explain..
I have many many entries with an (int)`status` column. I want to know if I can select the count of different types of statuses. In other words...
The entries are: 1,6,2,4,3,2,3,2,4,4,5,5,7,8,7
I want the results to be:
(1,1)
(6,1)
(2,3)
(4,3)
(3,2)
(5,2)
(7,2)
(8,1)
-- I think I counted those right.
In other words, I don't want to have to select ALL the status rows and add them up myself.
(current solution:)
better solution?:
I want to know "How many of each of the different status values are there?"
I have many many entries with an (int)`status` column. I want to know if I can select the count of different types of statuses. In other words...
The entries are: 1,6,2,4,3,2,3,2,4,4,5,5,7,8,7
I want the results to be:
(1,1)
(6,1)
(2,3)
(4,3)
(3,2)
(5,2)
(7,2)
(8,1)
-- I think I counted those right.
In other words, I don't want to have to select ALL the status rows and add them up myself.
(current solution:)
Code: Select all
SELECT `status`;
loop {
$status[`status`]++;
}I want to know "How many of each of the different status values are there?"