Re: Issue with adding ORDER BY to EXCEPT.

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Tim Vadnais <tvadnais(at)earthlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Issue with adding ORDER BY to EXCEPT.
Date: 2005-06-07 17:16:00
Message-ID: c2d9e70e050607101634764026@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> SELECT encounter.encounter_id, encounter_d.encounter_d_id
> FROM encounter
> JOIN encounter_d on encounter_d.encounter_id = encounter.encounter_id
> EXCEPT
> SELECT encounter.encounter_id, encounter_d.encounter_d_id
> FROM encounter
> JOIN encounter_d on encounter_d.encounter_id = encounter.encounter_id
> JOIN p_l_d ON p_l_d.patient_id = encounter.patient_mpi
> WHERE encounter_d.encounter_id = encounter.encounter_id
> AND ((p_l_d.start_date <= encounter_d.from_date OR p_l_d.start_date IS
> NULL)
> AND (p_l_d.end_date >= encounter_d.from_date OR p_l_d.end_date IS NULL))
> ORDER BY encounter.encounter_id, encounter_d.encounter_d_id

>
> With the ORDER BY
> NOTICE: adding missing FROM-clause entry for table "encounter"
> NOTICE: adding missing FROM-clause entry for table "encounter_d"
> ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the
> result columns
>
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!!

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dianne Yumul 2005-06-07 17:21:16 Re: Postgresql fails to start?
Previous Message Alvaro Herrera 2005-06-07 17:15:53 Re: locking question - why is this not a deadlock?

Browse pgsql-hackers by date

  From Date Subject
Next Message Scott Marlowe 2005-06-07 17:42:47 Re: Issue with adding ORDER BY to EXCEPT.
Previous Message Tim Vadnais 2005-06-07 16:58:18 Issue with adding ORDER BY to EXCEPT.