pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vladimir Terziev <vlady@school.digsys.bg>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Question about SELECT and ORDER BY
Date: Thu, 03 Feb 2000 12:46:29 -0500
Message-ID: <28465.949599989@sss.pgh.pa.us> (raw)
In-Reply-To: <200002031434.QAA01945@lorna.digsys.bg>
References: <200002031434.QAA01945@lorna.digsys.bg>

"Vladimir Terziev" <vlady@school.digsys.bg> writes:
> I have a query:
>    SELECT table1.attr1 AS ALIAS, attr2 from table1 UNION ALL
>    SELECT table2.attr1, attr3 from table2 ORDER BY ALIAS;

> I want to have a result from ORDER BY length(ALIAS), but this is imposible.

SELECT ... UNION ... ORDER BY is pretty broken in current sources;
in particular adding a hidden column to sort on doesn't work when
there's a UNION.  I've looked a little bit at fixing this, and it
looks like it will take the long-threatened querytree restructuring
to deal with it in any sensible fashion.  Maybe that'll happen for 7.1.

In the meantime use Mark Volpe's workaround of only sorting on
columns that are in the select list.

			regards, tom lane



view thread (3+ messages)

Message-ID: <28465.949599989@sss.pgh.pa.us>
Permalink:  ../28465.949599989@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28465.949599989@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, vlady@school.digsys.bg
  Subject: Re: [SQL] Question about SELECT and ORDER BY
  In-Reply-To: <28465.949599989@sss.pgh.pa.us>
  References: <200002031434.QAA01945@lorna.digsys.bg> <28465.949599989@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