I am trying to sort a table after a union all in SQL SERVER
I have read in several places (here for example: How to use order by with union all in sql?) that I need to write :
SELECT *
FROM
(
SELECT * FROM TABLE_A
UNION ALL
SELECT * FROM TABLE_B
) dum
-- ORDER BY .....
However, I keep getting an error saying :
Column 'dum.var' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
while I do not have any GROUP BY query ...
can someone explain this to me ?