From: A.M. <agentm@cmu.edu>
To: pgsql-sql@postgresql.org
Subject: UNION and ORDER BY ... IS NULL ASC
Date: Fri, 4 Apr 2003 20:58:38 -0500
Message-ID: <1E4E6631-670A-11D7-89FA-0030657192DA@cmu.edu> (raw)
PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.95.3
I have come across some unexpected behavior while dealing with a UNION
and ORDER BY. I'd like some advice. Here's a scenario where I want to
order by null values:
CREATE TABLE test(a int);
SELECT a FROM test UNION SELECT a FROM test ORDER BY a IS NULL ASC;
returns:
ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of
the result columns
whereas:
SELECT a FROM test UNION SELECT a FROM test ORDER BY a;
works fine. The column name is the same in both queries, yet I get an
error! Obviously, this is a gross oversimplification of what I want to
do, but I couldn't get it working in this minimal case. I also tried
using the column number, and that returns the same results as the name.
What am I doing wrong? Thanks for any info.
><><><><><><><><><
AgentM
agentm@cmu.edu
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: agentm@cmu.edu
Subject: Re: UNION and ORDER BY ... IS NULL ASC
In-Reply-To: <1E4E6631-670A-11D7-89FA-0030657192DA@cmu.edu>
References: <1E4E6631-670A-11D7-89FA-0030657192DA@cmu.edu>
* 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