I have previously written two articles on UNION and they are quite popular. I was reading SQL book Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes By Ben Forta and I came across three rules of UNION and I felt like mentioning them here.
UNION RULES
- A UNION must be composed of two or more SELECT statements, each separated by the keyword UNION.
- Each query in a UNION must contain the same columns, expressions, or aggregate functions, and they must be listed in the same order.
- Column datatypes must be compatible: They need not be the same exact same type, but they must be of a type that SQL Server can implicitly convert.
SQL SERVER - Union vs. Union All - Which is better for performance?
SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL
Reference: Pinal Dave (http://www.SQLAuthority.com), Ben Forta






But if union and then group by is good or directly using inner or outer join is better?