From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Richards <miker(at)scifair(dot)acadiau(dot)ca> |
Cc: | pgsql-sql(at)postgreSQL(dot)org, hackers(at)postgreSQL(dot)org |
Subject: | Re: Counting bool flags in a complex query |
Date: | 2000-10-06 05:01:47 |
Message-ID: | 24511.970808507@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
Quite awhile ago, Michael Richards <miker(at)scifair(dot)acadiau(dot)ca> wrote:
> It looks like the order by is only being applied to the original select,
> not the unioned select. Some authority should check on it, but by thought
> it that a union does not necessarily maintain the order, so the entire
> select should be applied to the order.
Just FYI, I have committed code for 7.1 that allows ORDER BY to work
correctly for a UNION'd query. A limitation is that you can only do
ordering on columns that are outputs of the UNION:
regression=# select q1 from int8_tbl union select q2 from int8_tbl order by 1;
q1
-------------------
-4567890123456789
123
456
4567890123456789
(4 rows)
regression=# select q1 from int8_tbl union select q2 from int8_tbl order by int8_tbl.q1+1;
ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the result columns
In the general case of an arbitrary ORDER BY expression, it's not clear
how to transpose it into each UNION source select anyway. It could
be made to work for expressions using only the output columns, but since
ORDER BY expressions are not standard SQL I'm not in a big hurry to make
that happen...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Kristofer Munn | 2000-10-06 05:06:08 | Exited with status 139 |
Previous Message | Philip Warner | 2000-10-06 04:26:24 | Re: ALTER TABLE DROP COLUMN |
From | Date | Subject | |
---|---|---|---|
Next Message | Saltsgaver, Scott | 2000-10-06 13:25:15 | RE: Granting of permissions on tables |
Previous Message | Tom Lane | 2000-10-05 21:37:49 | Re: Granting of permissions on tables |