pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Wickstrom <danw@rtp.ericsson.se>
To: pgsql-sql@postgresql.org
Subject: sum(bool)?
Date: Fri, 23 Feb 2001 10:45:11 -0500 (EST)
Message-ID: <14998.34183.16811.538101@gargle.gargle.HOWL> (raw)
In-Reply-To: <3A9681AD.55A3F355@soli-con.com>
References: <3A9681AD.55A3F355@soli-con.com>

>>>>> "Olaf" == Olaf Zanger <olaf.zanger@soli-con.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



view thread (10+ messages)  latest in thread

Message-ID: <14998.34183.16811.538101@gargle.gargle.HOWL>
Permalink:  ../14998.34183.16811.538101@gargle.gargle.HOWL/
Also on:    postgresql.org/message-id/14998.34183.16811.538101@gargle.gargle.HOWL

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: danw@rtp.ericsson.se
  Subject: Re: sum(bool)?
  In-Reply-To: <14998.34183.16811.538101@gargle.gargle.HOWL>
  References: <3A9681AD.55A3F355@soli-con.com> <14998.34183.16811.538101@gargle.gargle.HOWL>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox