From: | Andrew Perrin <aperrin(at)socrates(dot)berkeley(dot)edu> |
---|---|
To: | Daniel Wickstrom <danw(at)rtp(dot)ericsson(dot)se> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: sum(bool)? |
Date: | 2001-02-23 16:48:11 |
Message-ID: | Pine.LNX.4.21.0102231147520.3090-100000@nujoma.perrins |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Or how about just:
SELECT count(*) FROM tablename WHERE a > b;
----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology
Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin
aperrin(at)socrates(dot)berkeley(dot)edu - aperrin(at)igc(dot)apc(dot)org
On Fri, 23 Feb 2001, Daniel Wickstrom wrote:
> >>>>> "Olaf" == Olaf Zanger <olaf(dot)zanger(at)soli-con(dot)com> writes:
>
> Olaf> hi there i'd like to add up the "true" values of a
> Olaf> comparison like
>
> Olaf> sum(a>b)
>
> Olaf> it just doesn't work like this
>
> Olaf> any workaround
>
> Try using a case statement:
>
> select sum(case when a > b then 1 else 0 end) ....
>
>
> -Dan
>
From | Date | Subject | |
---|---|---|---|
Next Message | tjk@tksoft.com | 2001-02-23 18:14:29 | Re: How can i escape a '+' or a '+' in a regexp ? |
Previous Message | Peter Eisentraut | 2001-02-23 16:06:01 | Re: sum(bool)? |