I'm looking to write a Union between 2 tables where the 1st Union set of results appears before the second. (MSSQL 2014)
http://www.sqlfiddle.com/#!6/17c9e/74
I've noticed this question asked a few times but for whatever reason the accepted answers aren't working for me:
https://stackoverflow.com/questions/4076052/union-query-display-results-in-order-queries-are-written
https://stackoverflow.com/questions/13885261/order-result-sets-in-a-union
The 1st set of results returns:
userID FirstName LastName
-----------------------------
4 John Snow
5 Joffrey Baratheon
1 Tyrion Lanister
And the 2nd results return:
userID FirstName LastName
-----------------------------
5 Joffrey Baratheon
3 Daenerys Targaryen
1 Tyrion Lanister
Union gets rid of the duplicates which leaves userID 3 which should be appearing very last in my results. Final result:
userID FirstName LastName
-----------------------------
4 John Snow
5 Joffrey Baratheon
1 Tyrion Lanister
3 Daenerys Targaryen
The result I'm getting on SqlFiddle has userID -3 appearing second.
Any help appreciated.
4, 5, 1
order for the first set and5, 3, 1
for the second. It's pointless to try to meet your requirements without that, so I'm voting to put this on hold as unclear.