From Excel to SQL - Unions (UNION)
Unioning data in SQL is just "glueing" one result onto the bottom of another -- it combines the rows from two (or more!) results. Although there aren't any great examples with the AdventureWorks data, this is an important way to combine data in SQL. Note that if you're not using Microsoft SQL Server, check out the documentation for your SQL flavour to see whether ROLLUP is supported. The dbfiddle website can be accessed for free and without an account at: - https://dbfiddle.uk/ Make sure to use the SQL Server dialect and the AdventureWorks sample database to be able to follow along with these examples! --------------------------------------------------- This is part of the From Excel to SQL playlist, available at: - https://www.youtube.com/playlist?list=PLEiRgvTilK5rhnVPQ_Tj3Q-CI0rGn_uiD Check out the previous video at: - https://youtu.be/xG5CqLICKcY ...and the next video at: - https://youtu.be/pcD_7n7zKFw The written version of this content is also available at: - https://billwallis.github.io/sql-learning-materials/from-excel-to-sql/main-concepts/union/ --------------------------------------------------- CHAPTERS 00:00 dbfiddle 00:28 Intro 01:03 Using UNION 03:06 Multiple UNIONs 04:07 Rule: Column data types must match 05:48 Rule: Number of columns must match 06:11 UNION removes duplicates 06:58 UNION ALL keeps duplicates 07:28 Wrap up
Download
0 formatsNo download links available.