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

From Peter Eisentraut
Subject Re: sum(bool)?
Date
Msg-id Pine.LNX.4.30.0102231705070.1049-100000@peter.localdomain
Whole thread Raw
In response to sum(bool)?  (Olaf Zanger <olaf.zanger@soli-con.com>)
List pgsql-sql
Olaf Zanger writes:

> i'd like to add up the "true" values of a comparison like
>
> sum(a>b)

sum(case when a>b then 1 else 0 end)

of maybe even just

select count(*) from table where a>b;

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-sql by date:

Previous
From: Tod McQuillin
Date:
Subject: Re: sum(bool)?
Next
From: Olaf Zanger
Date:
Subject: Re: sum(bool)?