Changes between Version 3 and Version 4 of DAPS


Ignore:
Timestamp:
08/29/13 11:00:37 (11 years ago)
Author:
Richard Bramley
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DAPS

    v3 v4  
    6464 a. {{{USP_UPDATE_MATCH_5A_NHS_NO_MATCH}}}
    6565 a. {{{USP_UPDATE_MATCH_5B_CASENOTE_NUMBER_MATCH}}}
     66
     67
     68== Specific Runs
     69
     70=== Graphic 2 Extract of S Numbers
     71
     72{{{#!sql
     73WITH demo AS (
     74SELECT
     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
     86SELECT
     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
     99FROM    demo male
     100LEFT 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'
     104LEFT 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
     108WHERE   male.BATCH_ID = 10930 and male.GENDER = 'm'
     109
     110}}}