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