Re: sum(bool)?

From: Tod McQuillin <devin(at)spamcop(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 15:43:21
Message-ID: Pine.GSO.4.31.0102230941300.13223-100000@sysadmin
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Daniel Wickstrom 2001-02-23 15:45:11 sum(bool)?
Previous Message Tom Lane 2001-02-23 15:41:34 Re: AW: ask for help !!! (emergency case)