pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: vikrant@chemquick.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] SQL query problem
Date: Mon, 28 Feb 2000 02:38:03 -0500
Message-ID: <21249.951723483@sss.pgh.pa.us> (raw)
In-Reply-To: <200002280530.NAA12451@chemquick.com>
References: <200002280530.NAA12451@chemquick.com>

"Vikrant Rathore" <vikrant@chemquick.com> writes:
> I have been able to run the following query successfully on postgresl-
> 6.3.2 but unable to run the same in Postgresql-6.5.2.

> select 
> a.offer_id,a.comp_id,prod_name,date(offer_date),time(offer_date),
> ...
> group by a.offer_id
> ...

If you group by a.offer_id, then your select list can't refer to
any other columns except as aggregate-function arguments.  For
example, it would make sense to ask for min(a.comp_id) to get the
smallest comp_id out of each group of rows with the same offer_id.
But that group of rows doesn't necessarily all have the same comp_id,
so you can't expect to ask for unvarnished comp_id and get a well-
defined answer.

Before about v6.5, Postgres was fairly lax about checking for this
logical error (which is also a violation of the SQL standard), and
would in fact give you back some randomly-chosen comp_id value.
Recent versions detect the error, however.

			regards, tom lane



view thread (14+ messages)  latest in thread

Message-ID: <21249.951723483@sss.pgh.pa.us>
Permalink:  ../21249.951723483@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21249.951723483@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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, vikrant@chemquick.com
  Subject: Re: [SQL] SQL query problem
  In-Reply-To: <21249.951723483@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