Subject Re: [firebird-support] SQL Question Count() statistics
Author Helen Borrie
At 05:31 AM 17/10/2003 +0000, you wrote:
>How Can I write a SQL Query for this problem!!
>Ex table:
>
>Name True/False
>------- --------------
>John T
>Marie T
>Helen T
>Mike F
>John F
>Helen T
>Marie F
>.
>.
>.
>.
>.
>
>And requested result is!
>
>Name True Count False Count
>------- --------------- ----------------
>John 2 4
>Marie 6 9
>Helen 6 0
>.
>.
>.

select t1.Name,
count (*) as truecount,
(select count (*) from yourtable t2
where t2.Name = t1.Name
and t2.truefalse = 0) as falsecount
from yourtable t1
where t1.truefalse = 1
group by t1.Name

heLen