| 66 | |
| 67 | |
| 68 | == Specific Runs |
| 69 | |
| 70 | === Graphic 2 Extract of S Numbers |
| 71 | |
| 72 | {{{#!sql |
| 73 | WITH demo AS ( |
| 74 | SELECT |
| 75 | [SYSTEM_NUMBER_CURRENT] |
| 76 | ,[FORENAMES] |
| 77 | ,[SURNAME] |
| 78 | ,[POSTCODE] |
| 79 | ,[GENDER] |
| 80 | ,[DATE OF BIRTH] |
| 81 | ,[BATCH_ID] |
| 82 | ,[MATCH_DEMOGRAPHIC_LEVEL] |
| 83 | FROM [DWPATMATCH].[dbo].[DBS_TRACING] |
| 84 | ) |
| 85 | |
| 86 | SELECT |
| 87 | male.FORENAMES |
| 88 | ,male.SURNAME |
| 89 | ,male.[DATE OF BIRTH] |
| 90 | ,ISNULL(postcode.POSTCODE, '') [PostCode] |
| 91 | ,ISNULL(male.SYSTEM_NUMBER_CURRENT, '') [Male_S_Number] |
| 92 | ,ISNULL(female.SYSTEM_NUMBER_CURRENT, '') [Female_S_Number] |
| 93 | ,ISNULL(postcode.SYSTEM_NUMBER_CURRENT, '') [Postcode_S_Number] |
| 94 | ,COALESCE(male.SYSTEM_NUMBER_CURRENT, female.SYSTEM_NUMBER_CURRENT, postcode.SYSTEM_NUMBER_CURRENT, '') [S Number] |
| 95 | ,CASE WHEN (male.SYSTEM_NUMBER_CURRENT <> female.SYSTEM_NUMBER_CURRENT) |
| 96 | OR (male.SYSTEM_NUMBER_CURRENT <> postcode.SYSTEM_NUMBER_CURRENT) |
| 97 | OR (female.SYSTEM_NUMBER_CURRENT <> postcode.SYSTEM_NUMBER_CURRENT) |
| 98 | THEN 'Yes' ELSE '' END Mismatch |
| 99 | FROM demo male |
| 100 | LEFT JOIN demo female ON female.SURNAME = male.SURNAME |
| 101 | and female.FORENAMES = male.FORENAMES |
| 102 | and female.[DATE OF BIRTH] = male.[DATE OF BIRTH] |
| 103 | and female.BATCH_ID = 10930 and female.GENDER = 'f' |
| 104 | LEFT JOIN demo postcode ON postcode.SURNAME = male.SURNAME |
| 105 | and postcode.FORENAMES = male.FORENAMES |
| 106 | and postcode.[DATE OF BIRTH] = male.[DATE OF BIRTH] |
| 107 | and postcode.BATCH_ID = 10929 |
| 108 | WHERE male.BATCH_ID = 10930 and male.GENDER = 'm' |
| 109 | |
| 110 | }}} |