Created
November 7, 2016 15:14
-
-
Save Ryanb58/60279fea7deab130e4cdeee935f929cb to your computer and use it in GitHub Desktop.
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
Author: David Lund | |
IdentTypes | |
---- | |
ID Desc DataType | |
1 First Name Char | |
2 Last Name Char | |
3 SSN Char | |
4 StateId Int | |
5 Foo | |
Person | |
----------- | |
INT INT Varchar(max) | |
ID IdentTypeId Value | |
1 1 David | |
1 2 Lund | |
1 4 12 | |
2 1 Taylor | |
2 2 Brazelton | |
2 3 555112222 | |
select | |
a.Value as FirstName, | |
b.Value as LastName, | |
d.Value as State | |
from | |
Person a | |
left outer join Person b on a.ID = b.ID and b.IdentTypeId = 2 | |
left outer join Person c on a.ID = c.ID and c.IdentTypeId = 4 | |
left outer join StateTable d on c.Value = d.ID | |
where | |
a.IdentTypeId = 1 | |
and c.Value = 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment