Subject | ORDER BY in UNION SELECT |
---|---|
Author | moscow@cix.co.uk |
Post date | 2003-12-14T11:13Z |
I have the following code:
ID,
LongCol,
Medium,
Short,
'No ' as Guest,
Notes
FROM
Team
WHERE
(Short = '' OR Short IS NULL)
UNION
SELECT
ID,
LongCol,
Medium,
Short,
'Yes' as Guest,
Notes
FROM
Team
WHERE
Short = 'Guest'
ORDER BY 5,2
clause to use the actual field names (i.e.)
ORDER BY Guest, LongCol
but this results (in IBExpert, anyway) in an 'Invalid ORDER BY' message.
When not using a UNION (i.e. just one of the result sets), naming the
fields in the ORDER BY works as I would expect.
Is there a way around this?
Using FB1.5 Classic
Cheers
Terry Riley
>>>>>>>SELECT
ID,
LongCol,
Medium,
Short,
'No ' as Guest,
Notes
FROM
Team
WHERE
(Short = '' OR Short IS NULL)
UNION
SELECT
ID,
LongCol,
Medium,
Short,
'Yes' as Guest,
Notes
FROM
Team
WHERE
Short = 'Guest'
ORDER BY 5,2
>>>>>>>>Which works as advertised. However, I would prefer to have the ORDER BY
clause to use the actual field names (i.e.)
ORDER BY Guest, LongCol
but this results (in IBExpert, anyway) in an 'Invalid ORDER BY' message.
When not using a UNION (i.e. just one of the result sets), naming the
fields in the ORDER BY works as I would expect.
Is there a way around this?
Using FB1.5 Classic
Cheers
Terry Riley