Last active
April 6, 2017 12:41
-
-
Save mgrigajtis/ed997b08c5d2cd9f7c44b89050bd52f5 to your computer and use it in GitHub Desktop.
Worst Join So Far
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
#tmpResults t WITH (NOLOCK) | |
INNER JOIN table1 t1 WITH (NOLOCK) | |
ON t1.ALT_ID_WHO = 'M 17 ' + t.ALT_KEY | |
INNER JOIN table2 t2 WITH (NOLOCK) | |
ON SUBSTRING(t1.ALT_REF_ID,3,11) = t2.MemberNumber | |
AND CAST(CAST(t2.numericbeginningdate AS CHAR(8)) AS DATE) <= t.StartingDate | |
AND CAST(CAST(t2.numericendingdate AS CHAR(8)) AS DATE) >= t.StartingDate | |
AND t2.VOID <> 'V' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure you structure your data properly, otherwise you have to figure out joins that look like this.