Is there a way to union two tables, but keep the rows from the first table appearing first in the result set?
For example:
Table1
name
;WITH cte as ( SELECT name, surname, 1 as n FROM table1 UNION ALL SELECT name, surname, 2 as n FROM table2 UNION ALL SELECT name, surname, 3 as n FROM table3 ) SELECT name, surname FROM cte ORDER BY n;