Re: Issue with adding ORDER BY to EXCEPT.

From: "Tim Vadnais" <tvadnais(at)earthlink(dot)net>
To: "'Martijn van Oosterhout'" <kleptog(at)svana(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Issue with adding ORDER BY to EXCEPT.
Date: 2005-06-07 19:17:12
Message-ID: 20050607191722.4784D52939@svr1.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Perfect,

Thanks so much to all who assisted me.

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Martijn van
Oosterhout
Sent: Tuesday, June 07, 2005 10:51 AM
To: Scott Marlowe
Cc: Jaime Casanova; Tim Vadnais; pgsql-general(at)postgresql(dot)org; Hackers
Subject: Re: [GENERAL] Issue with adding ORDER BY to EXCEPT.

On Tue, Jun 07, 2005 at 12:42:47PM -0500, Scott Marlowe wrote:
> On Tue, 2005-06-07 at 12:16, Jaime Casanova wrote:
> > I suppose this is because the columns in the except are the same that
> > the ones in the main select and the order by get confused.
> >
> > i'm redirecting to hackers to know if this is a known bug or there is
> > something wrong in the select? i don't see anything wrong!!
>
> No, it's because to the order by, the column names are the ones given by
> the part after the period of the first select. If you do a plain select
> UNION select with no order by, you'll see the title for the columns is
> taken from the first select list column names.
>
> So, the order by needs to be "order by encounter_id, encounter_d_id

Or even easier:

order by 1, 2;

Then you don't even need to know the column names...
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2005-06-07 19:22:57 Re: Things I learned about PG8 on AIX5.3 with XLC compiler
Previous Message Mohan, Ross 2005-06-07 18:42:58 Things I learned about PG8 on AIX5.3 with XLC compiler

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew - Supernews 2005-06-07 19:20:43 Re: The Contrib Roundup (long)
Previous Message Robert Treat 2005-06-07 18:53:43 Re: The Contrib Roundup (long)