I have two queries that are "merged" with Union:
A
union
B
I want the result to be order by a specific column.
for example:
A
id sum dateissue
5 30 1.1.15
8 14 2.4.15
B
id sum dateissue
13 30 1.4.12
8 14 4.4.15
Desired result after Union with order by dateissue column:
id sum dateissue
13 30 1.4.12 : from B
5 30 1.1.15 : from A
8 14 2.4.15 : from A
8 14 4.4.15 : from B
I tried to do
(A)
Union
(B)
order by dateissue
but it gives error:
ERROR: column "dateissue" does not exist
How can I sort the result of the union?