Re: sum(bool)?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Olaf Zanger <olaf(dot)zanger(at)soli-con(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: sum(bool)?
Date: 2001-02-23 16:06:01
Message-ID: Pine.LNX.4.30.0102231705070.1049-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://yi.org/peter-e/

In response to

  • sum(bool)? at 2001-02-23 15:28:45 from Olaf Zanger

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Perrin 2001-02-23 16:48:11 Re: sum(bool)?
Previous Message Olaf Zanger 2001-02-23 15:58:06 Re: sum(bool)?