pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: joe.celko@trilogy.com
To: pgsql-sql@postgresql.org
Subject: Re: group by weirdness
Date: 14 Sep 2001 08:18:18 -0700
Message-ID: <7e67a7b3.0109140718.483315b9@posting.google.com> (raw)
References: <3B9D72B6.5050600@selectacast.net>

Would this give you what you want? 

 SELECT j.id, j.created, COUNT(mj.mid),
        SUM(CASE WHEN ml.state <> 11 THEN 1 ELSE 0 END) AS tally_1,
        SUM (CASE WHEN ml.state IN(2,5) THEN 1 ELSE 0 END)AS tally_2
   FROM j, mj, ml 
  WHERE j.fkey = 1 
    AND mj.jid = j.id 
    AND ml.jid = j.id;



view thread (7+ messages)  latest in thread

Message-ID: <7e67a7b3.0109140718.483315b9@posting.google.com>
Permalink:  ../7e67a7b3.0109140718.483315b9@posting.google.com/
Also on:    postgresql.org/message-id/7e67a7b3.0109140718.483315b9@posting.google.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: joe.celko@trilogy.com
  Subject: Re: group by weirdness
  In-Reply-To: <7e67a7b3.0109140718.483315b9@posting.google.com>

* 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