aggregates and case statements

From: Garry Saddington <garry(at)schoolteachers(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: aggregates and case statements
Date: 2008-11-16 17:39:52
Message-ID: 200811161739.52554.garry@schoolteachers.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is there a way to make the following statement return the total of all effort. At the moment it gives a list of sum vs case.

select sum(effort),
CASE WHEN effortandattainment.effort=5 THEN -3
WHEN effortandattainment.effort=4 THEN -2
WHEN effortandattainment.effort=3 THEN 1
WHEN effortandattainment.effort=2 THEN 2
WHEN effortandattainment.effort=1 THEN 3

END
from effortandattainment
group by case

Regards
Garry

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gerhard Heift 2008-11-16 23:35:50 avoid replace of column with variable in pgsql function
Previous Message Steve Atkins 2008-11-16 17:01:58 Re: Database access over the Internet...