sum(bool)?

From: Daniel Wickstrom <danw(at)rtp(dot)ericsson(dot)se>
To: pgsql-sql(at)postgresql(dot)org
Subject: sum(bool)?
Date: 2001-02-23 15:45:11
Message-ID: 14998.34183.16811.538101@gargle.gargle.HOWL
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>>>> "Olaf" == Olaf Zanger <olaf(dot)zanger(at)soli-con(dot)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

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 Olaf Zanger 2001-02-23 15:58:06 Re: sum(bool)?
Previous Message Tod McQuillin 2001-02-23 15:43:21 Re: sum(bool)?