Re: count( only if true)

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: count( only if true)
Дата
Msg-id 20051027044651.GA19670@wolff.to
обсуждение исходный текст
Ответ на Re: count( only if true)  (peter pilsl <pilsl@goldfisch.at>)
Список pgsql-general
On Wed, Oct 12, 2005 at 22:24:48 +0200,
  peter pilsl <pilsl@goldfisch.at> wrote:
>
> knowledge=# select x,count(case when id<5 then 't' else null end) from
> test2 group by x;
>  x | count
> ---+-------
>  e |     1          <--------- thats the result I want !!!
>  b |     1
>  c |     1
>  d |     0
>  a |     1
> (5 rows)

For simple cases like this you probably want to do the following:
SELECT x, count(*) FROM test2 WHERE id < 5 GROUP BY x

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Error Message
Следующее
От: David Garamond
Дата:
Сообщение: Re: Why database is corrupted after re-booting