tags:

views:

30

answers:

1

I have two queries

select TC,li,it as ee from results 
where li = "not_applicable" and cpirt = "uu_X1"

The above query will output 10 results, but If I put count in the same query, there is only one results.

select TC,li,it,COUNT(TC) as ee from results 
where li = "not_applicable" and cpirt = "uu_X1"

How can I make the second query output the counts for every TC using MYSQL

Thanks.

+3  A: 

Add GROUP BY TC.

I would do:

select TC,COUNT(TC) as ee from results 
where results.li = "not_applicable" and results.cpirt = "uu_X1"
GROUP BY TC
danben