group by / having

From: "Alain TESIO" <tesio(at)easynet(dot)fr>
To: <pgsql-sql(at)postgreSQL(dot)org>
Subject: group by / having
Date: 1999-12-19 14:28:59
Message-ID: 007f01bf4a2d$658a2800$f15f72c3@atesio
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert W. Berger 1999-12-19 18:08:11 select count(distinct ...
Previous Message neko 1999-12-19 09:47:44 Re: [SQL] NOTICE: (transaction aborted): queries ignored until END

Browse pgsql-sql by date

  From Date Subject
Next Message Alain TESIO 1999-12-19 16:04:40 group by / having
Previous Message tjk@tksoft.com 1999-12-19 10:20:33 Re: [SQL] making 'like' queries quicker