Re: count(1) return 0? - Mailing list pgsql-general

From Zak McGregor
Subject Re: count(1) return 0?
Date
Msg-id 20040301042831.7fd8f4ec.zak@mighty.co.za
Whole thread Raw
In response to Re: count(1) return 0?  (Klint Gore <kg@kgb.une.edu.au>)
List pgsql-general
On Mon, 01 Mar 2004 13:12:12 +1100
Klint Gore <kg@kgb.une.edu.au> wrote:

> The counting and grouping is done after the where clause is applied.
>
> since player iplaybadly (who was 1200's opponent) didnt win any, he/she
> is not included in the result set to be grouped and counted.  You need
> to get iplaybadly into the result set first.
>
> try something like
>
> select fixture, home, sum(case winner=home then 1 else 0 end)
> >from results
> group by fixture, home

Ah, thanks, works a charm.

Thanks too to all who offered help on this one.

Ciao

Zak

--
========================================================================
http://www.carfolio.com/        Searchable database of 10 000+ car specs
========================================================================

pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: A simple question (under pressure :-))....
Next
From: John Wells
Date:
Subject: elog: out of memory