Subject | Re: SQL Question Count() statistics |
---|---|
Author | tanz_anthrox |
Post date | 2003-10-17T09:02:41Z |
Thankyou Helen. It works. Superr
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> 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