agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-sql@hub.org
Subject: Re: [SQL] Re: "order by" weirdness
Date: Mon, 27 Sep 1999 09:47:15 -0400
Message-ID: <26126.938440035@sss.pgh.pa.us> (raw)
In-Reply-To: <19990927075232.4435.rocketmail@web117.yahoomail.com>
>> consider these three statements:
>>
>> create table t (id integer, date datetime ) ;
>> select id from t group by id ;
>> select id from t group by id order by max(date) ;
>>
>> Is it correct behavior that the second select returns
>> one row whereas the first select returns zero rows?
No, it is not. (Although it took a few rounds of discussion in the
mailing lists to get everyone to agree on that... if you check the
archives you will find this issue has come up repeatedly.)
I have in fact just fixed this in current sources. So, in 6.6 and
later, both statements will return zero rows if t is empty.
Note that with aggregates and no GROUP BY, you will get a row:
select count(id) from t ;
count
-----
0
(1 row)
select max(id) from t ;
max
---
(1 row)
which is correct behavior and will not change.
regards, tom lane
view thread (7+ messages) latest in thread
Message-ID: <26126.938440035@sss.pgh.pa.us>
Permalink: ../26126.938440035@sss.pgh.pa.us/
Also on: postgresql.org/message-id/26126.938440035@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, pgsql-sql@hub.org
Subject: Re: [SQL] Re: "order by" weirdness
In-Reply-To: <26126.938440035@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox