pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alain TESIO <tesio@easynet.fr>
To: pgsql-sql@postgreSQL.org
Subject: group by / having
Date: Sun, 19 Dec 1999 17:04:40 +0100
Message-ID: <00cb01bf4a3a$c6046a80$f15f72c3@atesio> (raw)

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





view thread (4+ messages)  latest in thread

Message-ID: <00cb01bf4a3a$c6046a80$f15f72c3@atesio>
Permalink:  ../00cb01bf4a3a$c6046a80$f15f72c3@atesio/
Also on:    postgresql.org/message-id/00cb01bf4a3a$c6046a80$f15f72c3@atesio

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tesio@easynet.fr
  Subject: Re: group by / having
  In-Reply-To: <00cb01bf4a3a$c6046a80$f15f72c3@atesio>
  References: <00cb01bf4a3a$c6046a80$f15f72c3@atesio>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox