tags:

views:

29

answers:

2

Hi,

I have table called stats. In am inserting yes or no in the table, and I want to show the number of yes count and the number of no count.

Can somebody please help me with the query?

+1  A: 
select yn, count(*)
from stats
group by yn;
ar
i dont have the yn field, i have only one field name is recommend tbl name is stats...
Bharanikumar
i tried somthing like this "SELECT count(recommend) FROM ".TBLRESULT." group by recommend ";
Bharanikumar
As you didn't bother to tell us what columns were in your table, I made up a column name.
ar
@Bharanikumar I'm downvoting your question as you failed to give the necessary information.
PP
+1  A: 

Try something like this

SELECT  SUM(CASE WHEN recommend = 'Y' THEN 1 ELSE 0 END) YesCount,
        SUM(CASE WHEN recommend = 'N' THEN 1 ELSE 0 END) NoCount,
        COUNT(*) TotalCount
FROM    Stats
astander
This what i asked..problem fixed
Bharanikumar
Bharanikumar: Please mark his response as the correct one... it's the empty thingy below the the point counter.
Helgi Hrafn Gunnarsson