Here are 2 queries -
select * --1
from Employee --2
where HireDate < '7/1/2001' --3
order by HireDate --4
--5 gap
select top(2) * --6
from Employee --7
where HireDate >= '7/1/2001' --8
order by HireDate --9
I want to do a UNION on them. When i put UNION in 5, why do i get an error?
When, I remove 4 and put UNION in 5, I get a result, but not the same as when I execute the two queries individually. Can you tell me why this happens?
To make this work correctly, I have to remove 4, make derived tables of both queries, put 4 after 9 and then perform a UNION of both derived tables.