Subject Re: [firebird-support] SQL query help
Author Ivan Prenosil
> I have a table column that stores the characters 'Y' or 'N'.
> I am trying to write a query that returns the number of 'Y's I have in
> relation to the total number of 'Y' and 'N' occurences.
> So if the column had Y,Y,Y,Y,N it would return 80 (%) or even
> something like 4,5 so that I can have the total number of 'Y's and the
> total number of rows.


select count(*), myfield
from tab
group by myfield;


select count(*), count(case when myfield='Y' then 1 end)
from tab;


select count(*), count(nullif(myfield, 'N'))
from tab;