From: James Taylor <jtx@hatesville.com>
To: pgsql-sql@postgresql.org
Subject: CASE
Date: Sun, 18 May 2003 23:59:46 -0700
Message-ID: <002201c31dd4$3f34c100$0000fea9@theplague> (raw)
Hi everyone, I'm trying to figure out how to get CASE working in a sum
aggregate function. Pretty simple query:
select sum(numbers) from lists where uid=1;
It's possible that there may be 0 rows where uid == 1. Instead of
returning 1 blank row, I want it to return '0'. So, I tried this:
select case(sum(numbers)) when null then 0 else sum(numbers) end from
list_results;
That... Doesn't work. Any suggestions on how to do this and where I can
find some decent information on use of CASE?
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: jtx@hatesville.com
Subject: Re: CASE
In-Reply-To: <002201c31dd4$3f34c100$0000fea9@theplague>
* 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