[snip]
I want count of all the records from leads table where status = 0 , status
=1, status = 3....etc. This should happen in a single query, is it possible?
[/snip]
Can we see a small snippet of the table you are querying? This would help. I
am sure it can be done with a crosstab like this;
select recordFoo,
sum(if(status = '0', 1, 0)) as Status0,
sum(if(status = '1', 1, 0)) as Status1,
sum(if(status = '2', 1, 0)) as Status2
from tblFoo
group by recordFoo
returns
+-----------+---------+---------+---------+
| recordFoo | Status0 | Status1 | Status2 |
+-----------+---------+---------+---------+
| thisFoo | 1 | 22 | 135 |
+-----------+---------+---------+---------+
| thatFoo | 3 | 1 | 2 |
+-----------+---------+---------+---------+
|theotherFoo| 0 | 871 | 8 |
+-----------+---------+---------+---------+
| moreFoo | 17 | 1118091 | 2 |
+-----------+---------+---------+---------+
HTH!
Jay