Closed GoogleCodeExporter closed 9 years ago
just found a workaround:
Using MIN() or MAX() on the PK solves the problem.
MySQL seems to automatically convert 'select PK, FK from TEST group by FK;' to
'select min(PK), FK from TEST group by FK;' to avoid SQLException.
drop table if exists TEST;
crate table TEST ( PK decimal(5) not nullL, FK decimal(5) not null );
insert into TEST (PK, FK) values (1, 101);
insert into TEST (PK, FK) values (2, 102);
insert into TEST (PK, FK) values (3, 102);
select max(PK), FK from TEST group by FK;
Original comment by beat.wir...@gmail.com
on 21 Apr 2009 at 6:25
select PK, FK from TEST group by FK;
It works in MySQL, but it is not supposed to work in standard SQL databases.
PostgreSQL: ERROR: column "test.pk" must appear in the GROUP BY clause or be
used in
an aggregate function 42803/0
Derby: 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.
Original comment by thomas.t...@gmail.com
on 21 Apr 2009 at 7:14
Original issue reported on code.google.com by
beat.wir...@gmail.com
on 21 Apr 2009 at 6:01