group by / having - Mailing list pgsql-sql

From Alain TESIO
Subject group by / having
Date
Msg-id 00cb01bf4a3a$c6046a80$f15f72c3@atesio
Whole thread Raw
Responses Re: [SQL] group by / having
List pgsql-sql
Hello,

Do you know why this command doesn't work ?

> select * from T;
x|y
-+-
1|1
1|2
2|1
2|2
2|3

> select X,Y from T group by X having Y=min(Y);

ERROR:  Illegal use of aggregates or non-group column in target list


My goal is quite simple : get only one line per X value (the value which is
returned for Y is not important as long as it's one of the values linked to
the right X).

The query "select X,Y from T group by X" works under MySQL and
returns exactly what I want, how can I do it in PostgreSQL ?

Thanks for your help,
Alain




pgsql-sql by date:

Previous
From: "Alain TESIO"
Date:
Subject: group by / having
Next
From: Tom Lane
Date:
Subject: Re: [SQL] group by / having