CASE

Поиск
Список
Период
Сортировка
От James Taylor
Тема CASE
Дата
Msg-id 002201c31dd4$3f34c100$0000fea9@theplague
обсуждение исходный текст
Ответы Re: CASE
Re: CASE
Re: CASE
Re: CASE
Список pgsql-sql
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?





В списке pgsql-sql по дате отправления:

Предыдущее
От: "Terry Yapt"
Дата:
Сообщение: Re: COALESCE in ORDER BY...
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Performance on temp table inserts