pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Giampiero Raschetti <Giampiero.Raschetti@popso.it>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] PgSQL 6.5.1 and Group BY pb
Date: Wed, 25 Aug 1999 10:07:43 -0400
Message-ID: <6045.935590063@sss.pgh.pa.us> (raw)
In-Reply-To: <37C3CEB9.AB63E3DE@popso.it>

Giampiero Raschetti <Giampiero.Raschetti@popso.it> writes:
> And now the output query with GROUP BY:

> template1=> SELECT g.nome,u.uid,u.id FROM gruppi g, usergroup u GROUP BY
> g.nome;
> ERROR:  Illegal use of aggregates or non-group column in target list
> template1=> SELECT nome,id FROM gruppi GROUP BY nome;
> ERROR:  Illegal use of aggregates or non-group column in target list

That is not a bug, it is the way things are supposed to work --- you
have variables in your SELECT that are not being grouped over, and are
not inside an aggregate function, so they have no well-defined value.

Postgres before 6.5 was not very good about catching this error all
the time, but 6.5 includes a more complete error check.

> And now the output query with SELECT DISTINCT:

> template1=> SELECT DISTINCT ON g.nome g.nome,u.uid,u.id from gruppi g,
> usergroup u;
> ERROR:  parser: parse error at or near "."

It looks like DISTINCT ON wants a plain unqualified column name.

DISTINCT ON is not standard SQL, and IMHO we ought to take it out ---
it's not well-defined.  It's got the same definitional problem as
non-group-by columns: what values of the other variables are you going
to get?

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <6045.935590063@sss.pgh.pa.us>
Permalink:  ../6045.935590063@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6045.935590063@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, Giampiero.Raschetti@popso.it
  Subject: Re: [SQL] PgSQL 6.5.1 and Group BY pb
  In-Reply-To: <6045.935590063@sss.pgh.pa.us>
  References: <37C3CEB9.AB63E3DE@popso.it> <6045.935590063@sss.pgh.pa.us>

* 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