Created
November 13, 2014 15:48
-
-
Save jtreher/40131798ee84df6259b4 to your computer and use it in GitHub Desktop.
This file contains 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
SELECT 1 AS ID | |
INTO #left | |
UNION | |
SELECT 2 | |
UNION | |
SELECT 3 | |
UNION | |
SELECT 4; | |
SELECT 1 AS ID | |
INTO #right | |
SELECT COUNT(*), tl.total | |
FROM #left l | |
left join #right r | |
on l.id = r.id | |
cross join | |
( | |
SELECT | |
COUNT(*) as total | |
, 0 as id | |
FROM #left | |
) tl | |
WHERE r.id IS NULL | |
GROUP BY tl.total; | |
DROP TABLE #left; | |
DROP TABLE #right; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment