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