Re: Unexpected behavior with CASE statement

Поиск
Список
Период
Сортировка
От Rodrigo De León
Тема Re: Unexpected behavior with CASE statement
Дата
Msg-id a55915760710031256i3d104d75g9280486199c61a82@mail.gmail.com
обсуждение исходный текст
Ответ на Unexpected behavior with CASE statement  ("Jimmy Choi" <yhjchoi@gmail.com>)
Ответы Re: Unexpected behavior with CASE statement  ("Jimmy Choi" <yhjchoi@gmail.com>)
Список pgsql-general
On 10/3/07, Jimmy Choi <yhjchoi@gmail.com> wrote:
> I expect to get the following result set:
>
> metric_type | result
> ------------+-------
>     0       |   2
>     1       |   3

Try:

SELECT   metric_type
       , SUM(CASE metric_type
               WHEN 0
                 THEN 1 / val
               WHEN 1
                 THEN val
             END) AS RESULT
    FROM metrics
GROUP BY metric_type
ORDER BY metric_type

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

Предыдущее
От: Brian Wipf
Дата:
Сообщение: Re: PITR and Compressed WALS
Следующее
От: "Jimmy Choi"
Дата:
Сообщение: Re: Unexpected behavior with CASE statement