db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oystein Grovlen - Sun Norway <Oystein.Grov...@Sun.COM>
Subject Re: Problem using group by order by in Derby 10.2.2.0
Date Fri, 22 Jun 2007 19:06:07 GMT
Chris Tsui wrote:
> Dear Sir,
> 
> I have created a table with following schema:
> 
> CREATE TABLE logging (
>   id bigint NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
>   nodeid bigint,
>   actor varchar(256) NOT NULL,
>   eventtime timestamp  default current_timestamp,
>   action varchar(256) NOT NULL,
>   objectname varchar(256) NOT NULL
> );
> 
> 
> When I executing query like
> 
> select max(eventtime) from logging where id > 10  group by action order 
> by eventtime desc ;
> 
> It returns
> ERROR 42Y30: The SELECT list of a grouped query contains at least one 
> invalid expression. If a SELECT list has a GROUP BY, the list may only 
> contain valid grouping expressions and valid aggregate expressions.
> 
> But it works without order by
> select max(eventtime) from logging where id > 10  group by action;

The error message is misleading here.  The problem is not the group by 
clause, but the order by clause.  Try 'order by 1' instead.

-- 
Øystein

Mime
View raw message