Re: sum(bool)? - Mailing list pgsql-sql

From Andrew Perrin
Subject Re: sum(bool)?
Date
Msg-id Pine.LNX.4.21.0102231147520.3090-100000@nujoma.perrins
Whole thread Raw
In response to sum(bool)?  (Daniel Wickstrom <danw@rtp.ericsson.se>)
List 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@socrates.berkeley.edu -
aperrin@igc.apc.org
On Fri, 23 Feb 2001, Daniel Wickstrom wrote:

> >>>>> "Olaf" == Olaf Zanger <olaf.zanger@soli-con.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
> 



pgsql-sql by date:

Previous
From: Olaf Zanger
Date:
Subject: Re: sum(bool)?
Next
From: Gabriel Fernandez
Date:
Subject: How can i escape a '+' or a '+' in a regexp ?