Created
January 27, 2016 09:03
-
-
Save dnasca/2cd6b7fcbc341ad0a183 to your computer and use it in GitHub Desktop.
Cross Joins - cross-product of two data sources, aka a Cartesian product. Each row from a data source is matched with ALL rows in the other data source. (DataSource1 * DataSource2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--how many rows? | |
SELECT COUNT(*) | |
FROM HumanResources.Employee; | |
--what gets returned? | |
SELECT e.BusinessEntityId, edh.DepartmentId | |
FROM HumanResources.Employee AS e | |
CROSS JOIN HumanREsources.EmployeeDepartmentHistory AS edh; | |
--practical use? | |
SELECT TOP 100000 | |
ROW_NUMBER() OVER (ORDER BY sv1.number) AS num | |
FROM [master].[dbo].[spt_values] AS sv1 | |
CROSS JOIN [master].[dbo].[spt_values] AS sv2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment