G
Guest
I want to order to results of just one SELECT statement within a larger UNION
query:
SELECT first_line FROM first_query
UNION ALL (SELECT second_group_of_lines FROM second_query ORDER BY
second_group_of_lines DESC)
UNION ALL SELECT third_line FROM third_query;
The idea is to create lines of text for a report. The second subquery
returns a few rows of data, which I want sorted within themselves, however
the first and third should remain separate. The result would be similar to:
6 meetings occured on Tuesday:
3 in the Boardroom
2 in the Auditorium
1 in the basement
These meetings lasted a total of 7 hours.
The detailed list of meetings (the three rows in the centre) needs to be
sorted, descending.
The above code returns no errors: the ORDER BY clause is simply ignored
completely.
Any ideas?
query:
SELECT first_line FROM first_query
UNION ALL (SELECT second_group_of_lines FROM second_query ORDER BY
second_group_of_lines DESC)
UNION ALL SELECT third_line FROM third_query;
The idea is to create lines of text for a report. The second subquery
returns a few rows of data, which I want sorted within themselves, however
the first and third should remain separate. The result would be similar to:
6 meetings occured on Tuesday:
3 in the Boardroom
2 in the Auditorium
1 in the basement
These meetings lasted a total of 7 hours.
The detailed list of meetings (the three rows in the centre) needs to be
sorted, descending.
The above code returns no errors: the ORDER BY clause is simply ignored
completely.
Any ideas?