๐จ SQL Fact Most Beginners Learn Too Late!
Many aspiring Data Analysts think these two SQL commands do the same thing... but they don't. ๐
๐ UNION
โ
Combines results and removes duplicates.
๐ UNION ALL
โ
Combines results and keeps duplicates.
Example:
Table A:
101
102
103
Table B:
103
104
105
๐น UNION โ 101, 102, 103, 104, 105
๐น UNION ALL โ 101, 102, 103, 103, 104, 105
๐ก This small difference can affect both your query results and performance. In fact, UNION ALL is usually faster because SQL doesn't need to remove duplicates.
๐ฏ A favorite SQL interview question that catches many beginners off guard!
โค๏ธ Drop a โค๏ธ if you learned something new today and follow for more SQL, Excel, Power BI & Data Analyst interview tips!
Post #2253
1.65K
- โค 4