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

From Tod McQuillin
Subject Re: sum(bool)?
Date
Msg-id Pine.GSO.4.31.0102230941300.13223-100000@sysadmin
Whole thread Raw
In response to sum(bool)?  (Olaf Zanger <olaf.zanger@soli-con.com>)
List pgsql-sql
On Fri, 23 Feb 2001, Olaf Zanger wrote:

> i'd like to add up the "true" values of a comparison like
>
> sum(a>b)
>
> it just doesn't work like this

Try
sum(case when a>b then 1 else 0 end)
-- 
Tod McQuillin




pgsql-sql by date:

Previous
From: Daniel Wickstrom
Date:
Subject: sum(bool)?
Next
From: Peter Eisentraut
Date:
Subject: Re: sum(bool)?