group by / having - Mailing list pgsql-sql

From Alain TESIO
Subject group by / having
Date
Msg-id 007f01bf4a2d$658a2800$f15f72c3@atesio
Whole thread Raw
In response to NOTICE: (transaction aborted): queries ignored until END  (Alex Guryanow <gav@nlr.ru>)
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: "tjk@tksoft.com"
Date:
Subject: Re: [SQL] making 'like' queries quicker
Next
From: "Alain TESIO"
Date:
Subject: group by / having