Re: group by weirdness

From: joe(dot)celko(at)trilogy(dot)com (--CELKO--)
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: group by weirdness
Date: 2001-09-14 15:18:18
Message-ID: 7e67a7b3.0109140718.483315b9@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-09-14 15:18:42 Re: SQL request change when upgrade from 7.0.2 to 7.1.3
Previous Message Peter Eisentraut 2001-09-14 14:10:09 Re: