SQL Interview: 12: Using UNION vs UNION ALL
This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Development Level: Intro
Question:
Consider the following code:
SELECT CustomerID, CustomerName FROM Sales.Customers WHERE BusinessCategory = 'Cafe' UNION SELECT CustomerID, CustomerName FROM Sales.Customers WHERE City = 'Toronto'; A: What would be the difference in results if the query was changed to use a UNION ALL instead of the UNION?
2021-04-22