Re: SQL feature requests - Mailing list pgsql-hackers

From Michael Glaesemann
Subject Re: SQL feature requests
Date
Msg-id F71C5143-6221-4355-8A10-4C921AB4E84E@seespotcode.net
Whole thread Raw
In response to Re: SQL feature requests  ("Ben Tilly" <btilly@gmail.com>)
Responses Re: SQL feature requests  ("Zeugswetter Andreas ADI SD" <Andreas.Zeugswetter@s-itsolutions.at>)
Re: SQL feature requests  ("Ben Tilly" <btilly@gmail.com>)
List pgsql-hackers
On Aug 22, 2007, at 20:49 , Ben Tilly wrote:

> If your implementation accepts:
>
>   group by case when true then 'foo' end

What would that mean? Regardless of whether or not it's accepted, it  
should have *some* meaning.

It's not equivalent to GROUP BY "foo"

test=# select record_id as foo    , count(observation_id) as bar    from observation    group by case when true
        then 'foo'             end;
 
ERROR:  column "observation.record_id" must appear in the GROUP BY  
clause or be used in an aggregate function
test=# select record_id       , count(observation_id) as bar       from observation       group by case when true
             then 'record_id'                end;
 
ERROR:  column "observation.record_id" must appear in the GROUP BY  
clause or be used in an aggregate function

*This* seems like a bug:
test=# select record_id       , count(observation_id) as bar       from observation       group by record_id
,case when true                  then 'foo'             end;
 
record_id | bar
-----------+-----         1 |   4         2 |   4         3 |   2
(3 rows)

And for good measure:

test=# select record_id       , count(observation_id) as bar       from observation       group by case when true
             then record_id                end;
 
ERROR:  column "observation.record_id" must appear in the GROUP BY  
clause or be used in an aggregate function

Michael Glaesemann
grzm seespotcode net




pgsql-hackers by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: SQL feature requests
Next
From: Tom Lane
Date:
Subject: Re: [COMMITTERS] pgsql: Add configure option --with-system-tzdata to use operating system