SQL 2005 Performance issue after a migration

  • I have recently migrated a datawarehouse from sql server 2000 to sql 2005. After the upgrade we have seen greately improved perfomance in most areas. however a few areas have suffered. The old sql 200 warehouse is still available for comparison although the data is now a few weeks old. One of the biggest issues i seem to be having is that queries written by the DW team that include a subquery (even if it is a simple subquery) is degrading performance severely. This issue does not exist in sql 2000.

    The query is below:

    SELECT TOP 1

    tbl_provider_spell.hospital_provider_spell_number,

    tbl_patient.pasid,

    tbl_patient.nhs_number,

    convert(datetime,convert(char(10),tbl_provider_spell.admission_date_dt,120),120),

    convert(datetime,convert(char(10),tbl_provider_spell.discharge_date_dt,120),120),

    count(distinct provider_spell_measures.hospital_provider_spell_number),

    tbl_provider_ipact.provider_code,

    tbl_admis_method_ipact.national_code,

    tbl_pat_class.national_code

    FROM

    tbl_admis_method tbl_admis_method_ipact INNER JOIN tbl_provider_spell ON (tbl_provider_spell.fk_admission_method=tbl_admis_method_ipact.pk_admis_method AND tbl_provider_spell.delete_flag='N')

    INNER JOIN tbl_consultant_episode ON (tbl_provider_spell.pk_provider_spell=tbl_consultant_episode.fk_provider_spell AND tbl_provider_spell.delete_flag='N' AND tbl_consultant_episode.delete_flag='N')

    INNER JOIN tbl_purchaser ON (tbl_consultant_episode.delete_flag='N' AND tbl_consultant_episode.fk_purchaser=tbl_purchaser.pk_purchaser)

    INNER JOIN tbl_pat_class ON (tbl_provider_spell.fk_patient_classification=tbl_pat_class.pk_pat_class AND tbl_provider_spell.delete_flag='N')

    INNER JOIN tbl_calendar Discharge_Date_Calendar ON (tbl_provider_spell.delete_flag='N' AND tbl_provider_spell.fk_cal_discharge_date_dt=Discharge_Date_Calendar.pk_calendar)

    INNER JOIN tbl_provider_spell provider_spell_measures ON (tbl_provider_spell.delete_flag='N' AND tbl_provider_spell.pk_provider_spell=provider_spell_measures.pk_provider_spell)

    INNER JOIN tbl_provider tbl_provider_ipact ON (tbl_provider_ipact.pk_provider=tbl_provider_spell.fk_provider AND tbl_provider_spell.delete_flag='N')

    INNER JOIN tbl_patient ON (tbl_provider_spell.delete_flag='N' AND tbl_patient.pk_patient=tbl_provider_spell.fk_patient AND tbl_patient.delete_flag = 'N')

    INNER JOIN tbl_gp ON (tbl_gp.pk_gp=tbl_patient.fk_gp AND tbl_patient.delete_flag = 'N')

    INNER JOIN tbl_pct tbl_pct_gp ON (tbl_pct_gp.pk_pct=tbl_gp.fk_pct)

    INNER JOIN tbl_pct tbl_pct_patient ON (tbl_pct_patient.pk_pct=tbl_patient.fk_pct AND tbl_patient.delete_flag = 'N')

    WHERE

    (

    Discharge_Date_Calendar.fy_year In ( '2008/09' )

    AND

    convert(datetime,convert(char(10),tbl_provider_spell.discharge_date_dt,120),120) BETWEEN '01/01/2009 00:0:0' AND '28/02/2009 00:0:0'

    AND

    ( tbl_consultant_episode.episode_number = 1 and tbl_consultant_episode.end_date_cons_episode_dt is not null )

    AND

    ( CASE

    WHEN tbl_purchaser.purchaser_code IN ('VPP00', 'TDH00', 'YDD82') THEN tbl_purchaser.purchaser_code

    WHEN NOT(ISNULL(tbl_pct_gp.pct_code, 'X9800') IN ('X9800', 'Q9900')) THEN tbl_pct_gp.pct_code

    WHEN NOT(ISNULL(tbl_pct_patient.pct_code, 'X9800') IN ('X9800', 'Q9900')) THEN tbl_pct_patient.pct_code

    ELSE tbl_purchaser.purchaser_code END In ( '5NM00','5J300','5J100' ) )

    AND

    ( tbl_admis_method_ipact.national_code IN ('21', '22', '23', '24', '28')

    AND EXISTS (

    SELECT 1

    FROM dbo.tbl_provider_spell ps_1

    INNER JOIN dbo.tbl_patient pat_1

    ON pat_1.pk_patient = ps_1.fk_patient

    INNER JOIN dbo.tbl_patient pat_2

    ON ISNULL(pat_2.nhs_number,pat_2.pasid) = ISNULL(pat_1.nhs_number,pat_1.pasid)

    INNER JOIN dbo.tbl_provider_spell ps_2

    ON ps_2.fk_patient = pat_2.pk_patient

    WHERE ps_1.pk_provider_spell = tbl_provider_spell.pk_provider_spell

    AND ps_1.pk_provider_spell <> ps_2.pk_provider_spell

    AND ps_1.admission_date_dt BETWEEN ps_2.discharge_date_dt AND DATEADD(d, 3, ps_2.discharge_date_dt)

    AND (CASE

    WHEN pat_2.pasid = pat_1.pasid THEN ps_1.pk_provider_spell

    ELSE ps_2.pk_provider_spell

    END) >= ps_2.pk_provider_spell

    )

    )

    )

    GROUP BY

    tbl_provider_spell.hospital_provider_spell_number,

    tbl_patient.pasid,

    tbl_patient.nhs_number,

    convert(datetime,convert(char(10),tbl_provider_spell.admission_date_dt,120),120),

    convert(datetime,convert(char(10),tbl_provider_spell.discharge_date_dt,120),120),

    tbl_provider_ipact.provider_code,

    tbl_admis_method_ipact.national_code,

    tbl_pat_class.national_code

    this takes two minutes on the 2000 box and runs for hours without completing on the 2005 box.

    can anyone give me any ideas

  • have you updated the stats post upgrade?

    Also generating execution plan can give you more option.

    As well running query with 'set statistics IO on' will give you information on read and write, which is another information you will get to judge the slowness.

    ----------
    Ashish

  • <ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.0" Build="9.00.4311.00">

    <BatchSequence>

    <Batch>

    <Statements>

    <StmtSimple StatementText="SELECT TOP 1 tbl_provider_spell.hospital_provider_spell_number, tbl_patient.pasid, tbl_patient.nhs_number, convert(datetime,convert(char(10),tbl_provider_spell.admission_date_dt,120),120), convert(datetime,convert(char(10),tbl_provider_spell.discharge_date_dt,120),120), count(distinct provider_spell_measures.hospital_provider_spell_number), tbl_provider_ipact.provider_code, tbl_admis_method_ipact.national_code, tbl_pat_class.national_code FROM tbl_admis_method tbl_admis_method_ipact INNER JOIN tbl_provider_spell ON (tbl_provider_spell.fk_admission_method=tbl_admis_method_ipact.pk_admis_method AND tbl_provider_spell.delete_flag='N') INNER JOIN tbl_consultant_episode ON (tbl_provider_spell.pk_provider_spell=tbl_consultant_episode.fk_provider_spell AND tbl_provider_spell.delete_flag='N' AND tbl_consultant_episode.delete_flag='N') INNER JOIN tbl_purchaser ON (tbl_consultant_episode.delete_flag='N' AND tbl_consultant_episode.fk_purchaser=tbl_purchaser.pk_purchaser) INNER JOIN tbl_pat_class ON (tbl_provider_spell.fk_patient_classification=tbl_pat_class.pk_pat_class AND tbl_provider_spell.delete_flag='N') INNER JOIN tbl_calendar Discharge_Date_Calendar ON (tbl_provider_spell.delete_flag='N' AND tbl_provider_spell.fk_cal_discharge_date_dt=Discharge_Date_Calendar.pk_calendar) INNER JOIN tbl_provider_spell provider_spell_measures ON (tbl_provider_spell.delete_flag='N' AND tbl_provider_spell.pk_provider_spell=provider_spell_measures.pk_provider_spell) INNER JOIN tbl_provider tbl_provider_ipact ON (tbl_provider_ipact.pk_provider=tbl_provider_spell.fk_provider AND tbl_provider_spell.delete_flag='N') INNER JOIN tbl_patient ON (tbl_provider_spell.delete_flag='N' AND tbl_patient.pk_patient=tbl_provider_spell.fk_patient AND tbl_patient.delete_flag = 'N') INNER JOIN tbl_gp ON (tbl_gp.pk_gp=tbl_patient.fk_gp AND tbl_patient.delete_flag = 'N') INNER JOIN tbl_pct tbl_pct_gp ON (tbl_pct_gp.pk_pct=tbl_gp.fk_pct) INNER JOIN tbl_pct tbl_pct_patient ON (tbl_pct_patient.pk_pct=tbl_patient.fk_pct AND tbl_patient.delete_flag = 'N') WHERE ( Discharge_Date_Calendar.fy_year In ( '2008/09' ) AND convert(datetime,convert(char(10),tbl_provider_spell.discharge_date_dt,120),120) BETWEEN '01/01/2009 00:0:0' AND '28/02/2009 00:0:0' AND ( tbl_consultant_episode.episode_number = 1 and tbl_consultant_episode.end_date_cons_episode_dt is not null ) AND ( CASE WHEN tbl_purchaser.purchaser_code IN ('VPP00', 'TDH00', 'YDD82') THEN tbl_purchaser.purchaser_code WHEN NOT(ISNULL(tbl_pct_gp.pct_code, 'X9800') IN ('X9800', 'Q9900')) THEN tbl_pct_gp.pct_code WHEN NOT(ISNULL(tbl_pct_patient.pct_code, 'X9800') IN ('X9800', 'Q9900')) THEN tbl_pct_patient.pct_code ELSE tbl_purchaser.purchaser_code END In ( '5NM00','5J300','5J100' ) ) AND ( tbl_admis_method_ipact.national_code IN ('21', '22', '23', '24', '28') AND EXISTS ( SELECT 1 FROM dbo.tbl_provider_spell ps_1 INNER JOIN dbo.tbl_patient pat_1 ON pat_1.pk_patient = ps_1.fk_patient INNER JOIN dbo.tbl_patient pat_2 ON ISNULL(pat_2.nhs_number,pat_2.pasid) = ISNULL(pat_1.nhs_number,pat_1.pasid) INNER JOIN dbo.tbl_provider_spell ps_2 ON ps_2.fk_patient = pat_2.pk_patient WHERE ps_1.pk_provider_spell = tbl_provider_spell.pk_provider_spell AND ps_1.pk_provider_spell <> ps_2.pk_provider_spell AND ps_1.admission_date_dt BETWEEN ps_2.discharge_date_dt AND DATEADD(d, 3, ps_2.discharge_date_dt) AND (CASE WHEN pat_2.pasid = pat_1.pasid THEN ps_1.pk_provider_spell ELSE ps_2.pk_provider_spell END) >= ps_2.pk_provider_spell ) ) ) GROUP BY tbl_provider_spell.hospital_provider_spell_number, tbl_patient.pasid, tbl_patient.nhs_number, convert(datetime,convert(char(10),tbl_provider_spell.admission_date_dt,120),120), convert(datetime,convert(char(10),tbl_provider_spell.discharge" StatementId="1" StatementCompId="1" StatementType="SELECT" StatementSubTreeCost="264.152" StatementEstRows="1" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="TimeOut">

    <StatementSetOptions QUOTED_IDENTIFIER="false" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="false" ANSI_NULLS="false" ANSI_PADDING="false" ANSI_WARNINGS="false" NUMERIC_ROUNDABORT="false"/>

    <QueryPlan CachedPlanSize="344" CompileTime="4318" CompileCPU="4318" CompileMemory="96976">

    <RelOp NodeId="0" PhysicalOp="Top" LogicalOp="Top" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-007" AvgRowSize="81" EstimatedTotalSubtreeCost="264.152" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    <ColumnReference Column="Expr1042"/>

    </OutputList>

    <Top RowCount="0" IsPercent="0" WithTies="0">

    <TopExpression>

    <ScalarOperator ScalarString="(1)">

    <Const ConstValue="(1)"/>

    </ScalarOperator>

    </TopExpression>

    <RelOp NodeId="1" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="6.32222e-005" AvgRowSize="81" EstimatedTotalSubtreeCost="264.152" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    <ColumnReference Column="Expr1042"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1042"/>

    <ScalarOperator ScalarString="CONVERT_IMPLICIT(int,[Expr1080],0)">

    <Convert DataType="int" Style="0" Implicit="1">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1080"/>

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="2" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="6.32222e-005" AvgRowSize="81" EstimatedTotalSubtreeCost="264.152" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    <ColumnReference Column="Expr1080"/>

    </OutputList>

    <StreamAggregate>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1080"/>

    <ScalarOperator ScalarString="Count(*)">

    <Aggregate AggType="countstar" Distinct="0"/>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <GroupBy>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    </GroupBy>

    <RelOp NodeId="3" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="5.74748e-005" AvgRowSize="88" EstimatedTotalSubtreeCost="264.152" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <StreamAggregate>

    <DefinedValues/>

    <GroupBy>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    </GroupBy>

    <RelOp NodeId="4" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0" EstimateCPU="0.00381235" AvgRowSize="88" EstimatedTotalSubtreeCost="264.152" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="0" WithOrderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Column="fk_pct"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    <ColumnReference Column="Expr1079"/>

    </OuterReferences>

    <RelOp NodeId="6" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="15.8686" EstimateIO="0" EstimateCPU="0.00381235" AvgRowSize="104" EstimatedTotalSubtreeCost="264.11" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Column="fk_pct"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="0" WithOrderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    <ColumnReference Column="Expr1078"/>

    </OuterReferences>

    <RelOp NodeId="8" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="15.8686" EstimateIO="0" EstimateCPU="0.00382785" AvgRowSize="104" EstimatedTotalSubtreeCost="264.055" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="0" WithOrderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    <ColumnReference Column="Expr1077"/>

    </OuterReferences>

    <RelOp NodeId="10" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="15.9331" EstimateIO="0.0112613" EstimateCPU="0.0141556" AvgRowSize="102" EstimatedTotalSubtreeCost="264.014" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0.566667" Output="1"/>

    <Sort Distinct="0">

    <OrderBy>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Column="Expr1040"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Column="Expr1041"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    </OrderByColumn>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    </OrderByColumn>

    </OrderBy>

    <RelOp NodeId="12" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="915.753" EstimateIO="0" EstimateCPU="0.00382785" AvgRowSize="102" EstimatedTotalSubtreeCost="263.989" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="0" WithUnorderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Column="Expr1076"/>

    </OuterReferences>

    <RelOp NodeId="14" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="915.753" EstimateIO="0" EstimateCPU="0.00382785" AvgRowSize="71" EstimatedTotalSubtreeCost="261.439" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="0" WithOrderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Column="Expr1075"/>

    </OuterReferences>

    <RelOp NodeId="16" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="915.753" EstimateIO="0.0112613" EstimateCPU="0.0141555" AvgRowSize="64" EstimatedTotalSubtreeCost="258.858" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0.213115" Output="0.433333"/>

    <Sort Distinct="0">

    <OrderBy>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    </OrderByColumn>

    </OrderBy>

    <RelOp NodeId="17" PhysicalOp="Merge Join" LogicalOp="Inner Join" EstimateRows="915.753" EstimateIO="0" EstimateCPU="0.0111975" AvgRowSize="64" EstimatedTotalSubtreeCost="258.833" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <Merge ManyToMany="0">

    <InnerSideJoinColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    </InnerSideJoinColumns>

    <OuterSideJoinColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="pk_purchaser"/>

    </OuterSideJoinColumns>

    <Residual>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_consultant_episode].[fk_purchaser]=[nhs_data_warehouse].[dbo].[tbl_purchaser].[pk_purchaser]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="pk_purchaser"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Residual>

    <RelOp NodeId="18" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="1706" EstimateIO="0.0179398" EstimateCPU="0.0020336" AvgRowSize="19" EstimatedTotalSubtreeCost="0.0199734" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="pk_purchaser"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="pk_purchaser"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Index="[PK_tbl_purchaser]"/>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="19" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="915.872" EstimateIO="0.0112613" EstimateCPU="0.0141576" AvgRowSize="62" EstimatedTotalSubtreeCost="258.802" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0.196721" Output="0.786885"/>

    <Sort Distinct="0">

    <OrderBy>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    </OrderByColumn>

    </OrderBy>

    <RelOp NodeId="21" PhysicalOp="Filter" LogicalOp="Filter" EstimateRows="915.872" EstimateIO="0" EstimateCPU="0.00137469" AvgRowSize="62" EstimatedTotalSubtreeCost="258.776" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <Filter StartupExpression="0">

    <RelOp NodeId="22" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="928.843" EstimateIO="0" EstimateCPU="0.00388257" AvgRowSize="69" EstimatedTotalSubtreeCost="258.775" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="delete_flag" ComputedColumn="1"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="end_date_cons_episode_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="episode_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="1" WithUnorderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="pk_consultant_episode"/>

    <ColumnReference Column="Expr1074"/>

    </OuterReferences>

    <RelOp NodeId="25" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="928.843" EstimateIO="0" EstimateCPU="0.00388257" AvgRowSize="62" EstimatedTotalSubtreeCost="255.803" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="pk_consultant_episode"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="1" WithUnorderedPrefetch="1">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Column="Expr1073"/>

    </OuterReferences>

    <RelOp NodeId="28" PhysicalOp="Merge Join" LogicalOp="Inner Join" EstimateRows="786.078" EstimateIO="0.0199724" EstimateCPU="0.0154013" AvgRowSize="57" EstimatedTotalSubtreeCost="253.759" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <Merge ManyToMany="1">

    <InnerSideJoinColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="pk_provider"/>

    </InnerSideJoinColumns>

    <OuterSideJoinColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    </OuterSideJoinColumns>

    <Residual>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider].[pk_provider] as [tbl_provider_ipact].[pk_provider]=[nhs_data_warehouse].[dbo].[tbl_provider_spell].[fk_provider]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="pk_provider"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Residual>

    <RelOp NodeId="29" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="786.128" EstimateIO="0.0112613" EstimateCPU="0.0118959" AvgRowSize="55" EstimatedTotalSubtreeCost="253.687" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0.786885" Output="0.163934"/>

    <Sort Distinct="0">

    <OrderBy>

    <OrderByColumn Ascending="1">

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    </OrderByColumn>

    </OrderBy>

    <RelOp NodeId="30" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="786.128" EstimateIO="0" EstimateCPU="0.104055" AvgRowSize="55" EstimatedTotalSubtreeCost="253.664" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0" Output="0"/>

    <Hash>

    <DefinedValues/>

    <HashKeysBuild>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_calendar]" Alias="[Discharge_Date_Calendar]" Column="pk_calendar"/>

    </HashKeysBuild>

    <HashKeysProbe>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    </HashKeysProbe>

    <RelOp NodeId="31" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="365" EstimateIO="0.003125" EstimateCPU="0.0005585" AvgRowSize="11" EstimatedTotalSubtreeCost="0.0036835" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_calendar]" Alias="[Discharge_Date_Calendar]" Column="pk_calendar"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_calendar]" Alias="[Discharge_Date_Calendar]" Column="pk_calendar"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_calendar]" Index="[IX_tbl_calendar_fy_year]" Alias="[Discharge_Date_Calendar]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_calendar]" Alias="[Discharge_Date_Calendar]" Column="fy_year"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'2008/09'">

    <Const ConstValue="'2008/09'"/>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="32" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="17955" EstimateIO="0" EstimateCPU="0.159925" AvgRowSize="60" EstimatedTotalSubtreeCost="253.557" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0" Output="0"/>

    <Hash>

    <DefinedValues/>

    <HashKeysBuild>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="pk_pat_class"/>

    </HashKeysBuild>

    <HashKeysProbe>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient_classification"/>

    </HashKeysProbe>

    <RelOp NodeId="33" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="8" EstimateIO="0.003125" EstimateCPU="0.0001658" AvgRowSize="16" EstimatedTotalSubtreeCost="0.0032908" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="pk_pat_class"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    </OutputList>

    <IndexScan Ordered="0" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="pk_pat_class"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Column="national_code"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pat_class]" Index="[PK_tbl_pat_class]"/>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="34" PhysicalOp="Nested Loops" LogicalOp="Left Semi Join" EstimateRows="28030.1" EstimateIO="0" EstimateCPU="0.117166" AvgRowSize="61" EstimatedTotalSubtreeCost="253.393" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient_classification"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    </OuterReferences>

    <RelOp NodeId="35" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="28030.1" EstimateIO="0" EstimateCPU="0.424049" AvgRowSize="61" EstimatedTotalSubtreeCost="8.91692" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient_classification"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <MemoryFractions Input="0" Output="0"/>

    <Hash>

    <DefinedValues/>

    <HashKeysBuild>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="pk_admis_method"/>

    </HashKeysBuild>

    <HashKeysProbe>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_admission_method"/>

    </HashKeysProbe>

    <RelOp NodeId="36" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="5" EstimateIO="0.003125" EstimateCPU="0.0001625" AvgRowSize="17" EstimatedTotalSubtreeCost="0.0032875" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="pk_admis_method"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="pk_admis_method"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Index="[IX_tbl_admis_method_national_code]" Alias="[tbl_admis_method_ipact]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'21'">

    <Const ConstValue="'21'"/>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'22'">

    <Const ConstValue="'22'"/>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'23'">

    <Const ConstValue="'23'"/>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'24'">

    <Const ConstValue="'24'"/>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_admis_method]" Alias="[tbl_admis_method_ipact]" Column="national_code"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="'28'">

    <Const ConstValue="'28'"/>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="37" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="84090.3" EstimateIO="0" EstimateCPU="0.0934345" AvgRowSize="62" EstimatedTotalSubtreeCost="5.70524" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_admission_method"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient_classification"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    <ColumnReference Column="Expr1040"/>

    <ColumnReference Column="Expr1041"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1040"/>

    <ScalarOperator ScalarString="CONVERT(datetime,CONVERT(char(10),[nhs_data_warehouse].[dbo].[tbl_provider_spell].[admission_date_dt],120),120)">

    <Convert DataType="datetime" Style="120" Implicit="0">

    <ScalarOperator>

    <Convert DataType="char" Length="10" Style="120" Implicit="0">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="admission_date_dt"/>

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Column="Expr1041"/>

    <ScalarOperator ScalarString="CONVERT(datetime,CONVERT(char(10),[nhs_data_warehouse].[dbo].[tbl_provider_spell].[discharge_date_dt],120),120)">

    <Convert DataType="datetime" Style="120" Implicit="0">

    <ScalarOperator>

    <Convert DataType="char" Length="10" Style="120" Implicit="0">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="discharge_date_dt"/>

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="38" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="84090.3" EstimateIO="4.58387" EstimateCPU="1.02794" AvgRowSize="54" EstimatedTotalSubtreeCost="5.6118" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_admission_method"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient_classification"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="admission_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="discharge_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    </OutputList>

    <IndexScan Ordered="0" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_admission_method"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_cal_discharge_date_dt"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient_classification"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_provider"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="admission_date_dt"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="discharge_date_dt"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="hospital_provider_spell_number"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Index="[Test]"/>

    <Predicate>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[delete_flag]='N' AND CONVERT(datetime,CONVERT(char(10),[nhs_data_warehouse].[dbo].[tbl_provider_spell].[discharge_date_dt],120),120)>='2009-01-01 00:00:00.000' AND CONVERT(datetime,CONVERT(char(10),[nhs_data_warehouse].[dbo].[tbl_provider_spell].[discharge_date_dt],120),120)<='2009-02-28 00:00:00.000'">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <Convert DataType="datetime" Style="120" Implicit="0">

    <ScalarOperator>

    <Convert DataType="char" Length="10" Style="120" Implicit="0">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="discharge_date_dt"/>

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'2009-01-01 00:00:00.000'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Convert DataType="datetime" Style="120" Implicit="0">

    <ScalarOperator>

    <Convert DataType="char" Length="10" Style="120" Implicit="0">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="discharge_date_dt"/>

    </Identifier>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'2009-02-28 00:00:00.000'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Hash>

    </RelOp>

    <RelOp NodeId="45" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0" EstimateCPU="0.486456" AvgRowSize="9" EstimatedTotalSubtreeCost="244.359" Parallel="0" EstimateRebinds="28029.1" EstimateRewinds="0">

    <OutputList/>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    </OuterReferences>

    <RelOp NodeId="46" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1.42123" EstimateIO="0" EstimateCPU="23.7501" AvgRowSize="53" EstimatedTotalSubtreeCost="184.404" Parallel="0" EstimateRebinds="28029.1" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    </OutputList>

    <NestedLoops Optimized="0">

    <Predicate>

    <ScalarOperator ScalarString="[Expr1057]=[Expr1058]">

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1057"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1058"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Predicate>

    <RelOp NodeId="47" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-007" AvgRowSize="45" EstimatedTotalSubtreeCost="178.955" Parallel="0" EstimateRebinds="28029.1" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    <ColumnReference Column="Expr1058"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1058"/>

    <ScalarOperator ScalarString="isnull([nhs_data_warehouse].[dbo].[tbl_patient].[nhs_number] as [pat_1].[nhs_number],[nhs_data_warehouse].[dbo].[tbl_patient].[pasid] as [pat_1].[pasid])">

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="nhs_number"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    </Identifier>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="48" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0" EstimateCPU="4.18e-006" AvgRowSize="44" EstimatedTotalSubtreeCost="178.952" Parallel="0" EstimateRebinds="28029.1" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    </OutputList>

    <NestedLoops Optimized="0">

    <OuterReferences>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="fk_patient"/>

    </OuterReferences>

    <RelOp NodeId="49" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="19" EstimatedTotalSubtreeCost="87.5945" Parallel="0" EstimateRebinds="28029.1" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="fk_patient"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Index="[PK_tbl_provider_spell]" Alias="[ps_1]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    <RelOp NodeId="50" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="36" EstimatedTotalSubtreeCost="91.2405" Parallel="0" EstimateRebinds="28029.1" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="nhs_number"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Index="[PK_tbl_patient]" Alias="[pat_1]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pk_patient"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[fk_patient] as [ps_1].[fk_patient]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="fk_patient"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    <RelOp NodeId="54" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="69.3882" EstimateIO="0" EstimateCPU="0.568185" AvgRowSize="41" EstimatedTotalSubtreeCost="2.33925" Parallel="0" EstimateRebinds="0" EstimateRewinds="28029.1">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    <ColumnReference Column="Expr1057"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1057"/>

    <ScalarOperator ScalarString="isnull([nhs_data_warehouse].[dbo].[tbl_patient].[nhs_number] as [pat_2].[nhs_number],[nhs_data_warehouse].[dbo].[tbl_patient].[pasid] as [pat_2].[pasid])">

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="nhs_number"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    </Identifier>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="55" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="69.3882" EstimateIO="167.51" EstimateCPU="6.25012" AvgRowSize="40" EstimatedTotalSubtreeCost="2.14475" Parallel="0" EstimateRebinds="0" EstimateRewinds="28029.1">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    </OutputList>

    <IndexScan Ordered="0" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pk_patient"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="nhs_number"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Index="[PK_tbl_patient]" Alias="[pat_2]"/>

    </IndexScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="60" PhysicalOp="Filter" LogicalOp="Filter" EstimateRows="1" EstimateIO="0" EstimateCPU="1.68e-006" AvgRowSize="9" EstimatedTotalSubtreeCost="59.7883" Parallel="0" EstimateRebinds="67866" EstimateRewinds="0">

    <OutputList/>

    <Filter StartupExpression="0">

    <RelOp NodeId="61" PhysicalOp="Index Spool" LogicalOp="Eager Spool" EstimateRows="1" EstimateIO="24.2902" EstimateCPU="0.934603" AvgRowSize="15" EstimatedTotalSubtreeCost="59.6743" Parallel="0" EstimateRebinds="67866" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    <ColumnReference Column="Expr1056"/>

    </OutputList>

    <Spool>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="fk_patient"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_patient].[pk_patient] as [pat_2].[pk_patient]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pk_patient"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    <EndRange ScanType="LE">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="discharge_date_dt"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[admission_date_dt] as [ps_1].[admission_date_dt]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </EndRange>

    </SeekPredicate>

    <RelOp NodeId="62" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="934345" EstimateIO="0" EstimateCPU="0.0934345" AvgRowSize="23" EstimatedTotalSubtreeCost="5.70524" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="discharge_date_dt"/>

    <ColumnReference Column="Expr1056"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Column="Expr1056"/>

    <ScalarOperator ScalarString="dateadd(day,(3),[nhs_data_warehouse].[dbo].[tbl_provider_spell].[discharge_date_dt] as [ps_2].[discharge_date_dt])">

    <Intrinsic FunctionName="dateadd">

    <ScalarOperator>

    <Const ConstValue="(4)"/>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(3)"/>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="discharge_date_dt"/>

    </Identifier>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="63" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="934345" EstimateIO="4.58387" EstimateCPU="1.02794" AvgRowSize="19" EstimatedTotalSubtreeCost="5.6118" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="fk_patient"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="discharge_date_dt"/>

    </OutputList>

    <IndexScan Ordered="0" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="fk_patient"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="discharge_date_dt"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Index="[Test]" Alias="[ps_2]"/>

    </IndexScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Spool>

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell] as [ps_1].[pk_provider_spell]<>[nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell] as [ps_2].[pk_provider_spell] AND [nhs_data_warehouse].[dbo].[tbl_provider_spell].[admission_date_dt] as [ps_1].[admission_date_dt]<=[Expr1056] AND CASE WHEN [nhs_data_warehouse].[dbo].[tbl_patient].[pasid] as [pat_2].[pasid]=[nhs_data_warehouse].[dbo].[tbl_patient].[pasid] as [pat_1].[pasid] THEN [nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell] as [ps_1].[pk_provider_spell] ELSE [nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell] as [ps_2].[pk_provider_spell] END>=[nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell] as [ps_2].[pk_provider_spell]">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="LE">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="admission_date_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Column="Expr1056"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="GE">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_2]" Column="pasid"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Alias="[pat_1]" Column="pasid"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_1]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[ps_2]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </Hash>

    </RelOp>

    </Hash>

    </RelOp>

    </Sort>

    </RelOp>

    <RelOp NodeId="70" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="2409" EstimateIO="0.0334954" EstimateCPU="0.0028069" AvgRowSize="19" EstimatedTotalSubtreeCost="0.0363023" Parallel="0" EstimateRebinds="0" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="pk_provider"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="pk_provider"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Alias="[tbl_provider_ipact]" Column="provider_code"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider]" Index="[pk_tbl_provider]" Alias="[tbl_provider_ipact]"/>

    </IndexScan>

    </RelOp>

    </Merge>

    </RelOp>

    <RelOp NodeId="72" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="1.18162" EstimateIO="0.003125" EstimateCPU="0.0001583" AvgRowSize="15" EstimatedTotalSubtreeCost="2.03985" Parallel="0" EstimateRebinds="785.078" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="pk_consultant_episode"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="pk_consultant_episode"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Index="[IX_tbl_consultant_episode_fk_provider_spell]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[pk_provider_spell]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="pk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="74" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-007" AvgRowSize="18" EstimatedTotalSubtreeCost="2.96784" Parallel="0" EstimateRebinds="927.843" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="delete_flag" ComputedColumn="1"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="end_date_cons_episode_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="episode_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="delete_flag" ComputedColumn="1"/>

    <ScalarOperator ScalarString="CONVERT(char(1),CASE WHEN [nhs_data_warehouse].[dbo].[tbl_consultant_episode].[deleted_date_dt] IS NOT NULL THEN 'Y' ELSE 'N' END,0)">

    <Convert DataType="char" Length="1" Style="0" Implicit="0">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="deleted_date_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Const ConstValue="'Y'"/>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="75" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="25" EstimatedTotalSubtreeCost="2.96774" Parallel="0" EstimateRebinds="927.843" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="deleted_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="end_date_cons_episode_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="episode_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    </OutputList>

    <IndexScan Lookup="1" Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="deleted_date_dt"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="end_date_cons_episode_dt"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="episode_number"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_purchaser"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Index="[PK_tbl_consultant_episode]" TableReferenceId="-1"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="pk_consultant_episode"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_consultant_episode].[pk_consultant_episode]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="pk_consultant_episode"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_consultant_episode].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_consultant_episode].[delete_flag]='N' AND [nhs_data_warehouse].[dbo].[tbl_consultant_episode].[episode_number]=(1) AND [nhs_data_warehouse].[dbo].[tbl_consultant_episode].[end_date_cons_episode_dt] IS NOT NULL">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="delete_flag" ComputedColumn="1"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="episode_number"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="(1)"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="end_date_cons_episode_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    </Sort>

    </RelOp>

    </Merge>

    </RelOp>

    </Sort>

    </RelOp>

    <RelOp NodeId="89" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="20" EstimatedTotalSubtreeCost="2.57675" Parallel="0" EstimateRebinds="914.556" EstimateRewinds="0.197227">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="hospital_provider_spell_number"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Index="[PK_tbl_provider_spell]" Alias="[provider_spell_measures]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Alias="[provider_spell_measures]" Column="pk_provider_spell"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_consultant_episode].[fk_provider_spell]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_consultant_episode]" Column="fk_provider_spell"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="90" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-007" AvgRowSize="45" EstimatedTotalSubtreeCost="2.54502" Parallel="0" EstimateRebinds="773.907" EstimateRewinds="140.846">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="delete_flag" ComputedColumn="1"/>

    </OutputList>

    <ComputeScalar>

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="delete_flag" ComputedColumn="1"/>

    <ScalarOperator ScalarString="CONVERT(char(1),CASE WHEN [nhs_data_warehouse].[dbo].[tbl_patient].[deleted_date_dt] IS NOT NULL THEN 'Y' ELSE 'N' END,0)">

    <Convert DataType="char" Length="1" Style="0" Implicit="0">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="deleted_date_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Const ConstValue="'Y'"/>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    </DefinedValue>

    </DefinedValues>

    <RelOp NodeId="91" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="52" EstimatedTotalSubtreeCost="2.54493" Parallel="0" EstimateRebinds="773.907" EstimateRewinds="140.846">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="deleted_date_dt"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="deleted_date_dt"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="nhs_number"/>

    </DefinedValue>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pasid"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Index="[PK_tbl_patient]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="pk_patient"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_provider_spell].[fk_patient]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_provider_spell]" Column="fk_patient"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    <Predicate>

    <ScalarOperator ScalarString="CONVERT(char(1),CASE WHEN [nhs_data_warehouse].[dbo].[tbl_patient].[deleted_date_dt] IS NOT NULL THEN 'Y' ELSE 'N' END,0)='N' AND CONVERT(char(1),CASE WHEN [nhs_data_warehouse].[dbo].[tbl_patient].[deleted_date_dt] IS NOT NULL THEN 'Y' ELSE 'N' END,0)='N' AND CONVERT(char(1),CASE WHEN [nhs_data_warehouse].[dbo].[tbl_patient].[deleted_date_dt] IS NOT NULL THEN 'Y' ELSE 'N' END,0)='N'">

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Convert DataType="char" Length="1" Style="0" Implicit="0">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="deleted_date_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Const ConstValue="'Y'"/>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Convert DataType="char" Length="1" Style="0" Implicit="0">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="deleted_date_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Const ConstValue="'Y'"/>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Convert DataType="char" Length="1" Style="0" Implicit="0">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Compare CompareOp="IS NOT">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="deleted_date_dt"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="NULL"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Const ConstValue="'Y'"/>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Convert>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'N'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </IndexScan>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </Sort>

    </RelOp>

    <RelOp NodeId="96" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0407205" Parallel="0" EstimateRebinds="15.3633" EstimateRewinds="0.556766">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Index="[PK_tbl_pct]" Alias="[tbl_pct_patient]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pk_pct"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_patient].[fk_pct]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_pct"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="97" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="11" EstimatedTotalSubtreeCost="0.0547127" Parallel="0" EstimateRebinds="15.8504" EstimateRewinds="0.0173989">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Column="fk_pct"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Column="fk_pct"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Index="[PK_tbl_gp]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Column="pk_gp"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_patient].[fk_gp]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_patient]" Column="fk_gp"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    </NestedLoops>

    </RelOp>

    <RelOp NodeId="98" PhysicalOp="Filter" LogicalOp="Filter" EstimateRows="1" EstimateIO="0" EstimateCPU="1.258e-005" AvgRowSize="9" EstimatedTotalSubtreeCost="0.0421541" Parallel="0" EstimateRebinds="16" EstimateRewinds="0">

    <OutputList/>

    <Filter StartupExpression="0">

    <RelOp NodeId="99" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0419402" Parallel="0" EstimateRebinds="16" EstimateRewinds="0">

    <OutputList>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </OutputList>

    <IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" NoExpandHint="0">

    <DefinedValues>

    <DefinedValue>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </DefinedValue>

    </DefinedValues>

    <Object Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Index="[PK_tbl_pct]" Alias="[tbl_pct_gp]"/>

    <SeekPredicates>

    <SeekPredicate>

    <Prefix ScanType="EQ">

    <RangeColumns>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pk_pct"/>

    </RangeColumns>

    <RangeExpressions>

    <ScalarOperator ScalarString="[nhs_data_warehouse].[dbo].[tbl_gp].[fk_pct]">

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_gp]" Column="fk_pct"/>

    </Identifier>

    </ScalarOperator>

    </RangeExpressions>

    </Prefix>

    </SeekPredicate>

    </SeekPredicates>

    </IndexScan>

    </RelOp>

    <Predicate>

    <ScalarOperator ScalarString="CASE WHEN [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='YDD82' OR [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='TDH00' OR [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='VPP00' THEN [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code] ELSE CASE WHEN isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code],'X9800')<>'Q9900' AND isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code],'X9800')<>'X9800' THEN [nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code] ELSE CASE WHEN isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code],'X9800')<>'Q9900' AND isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code],'X9800')<>'X9800' THEN [nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code] ELSE [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code] END END END='5J100' OR CASE WHEN [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='YDD82' OR [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='TDH00' OR [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='VPP00' THEN [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code] ELSE CASE WHEN isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code],'X9800')<>'Q9900' AND isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code],'X9800')<>'X9800' THEN [nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code] ELSE CASE WHEN isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code],'X9800')<>'Q9900' AND isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code],'X9800')<>'X9800' THEN [nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code] ELSE [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code] END END END='5J300' OR CASE WHEN [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='YDD82' OR [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='TDH00' OR [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code]='VPP00' THEN [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code] ELSE CASE WHEN isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code],'X9800')<>'Q9900' AND isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code],'X9800')<>'X9800' THEN [nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_gp].[pct_code] ELSE CASE WHEN isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code],'X9800')<>'Q9900' AND isnull([nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code],'X9800')<>'X9800' THEN [nhs_data_warehouse].[dbo].[tbl_pct].[pct_code] as [tbl_pct_patient].[pct_code] ELSE [nhs_data_warehouse].[dbo].[tbl_purchaser].[purchaser_code] END END END='5NM00'">

    <Logical Operation="OR">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="OR">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'YDD82'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'TDH00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'VPP00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'Q9900'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'Q9900'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'5J100'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="OR">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'YDD82'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'TDH00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'VPP00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'Q9900'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'Q9900'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'5J300'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="OR">

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'YDD82'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'TDH00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="EQ">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'VPP00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'Q9900'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_gp]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <IF>

    <Condition>

    <ScalarOperator>

    <Logical Operation="AND">

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'Q9900'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    <ScalarOperator>

    <Compare CompareOp="NE">

    <ScalarOperator>

    <Intrinsic FunctionName="isnull">

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Intrinsic>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'X9800'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Condition>

    <Then>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_pct]" Alias="[tbl_pct_patient]" Column="pct_code"/>

    </Identifier>

    </ScalarOperator>

    </Then>

    <Else>

    <ScalarOperator>

    <Identifier>

    <ColumnReference Database="[nhs_data_warehouse]" Schema="[dbo]" Table="[tbl_purchaser]" Column="purchaser_code"/>

    </Identifier>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    </Else>

    </IF>

    </ScalarOperator>

    <ScalarOperator>

    <Const ConstValue="'5NM00'"/>

    </ScalarOperator>

    </Compare>

    </ScalarOperator>

    </Logical>

    </ScalarOperator>

    </Predicate>

    </Filter>

    </RelOp>

    </NestedLoops>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </StreamAggregate>

    </RelOp>

    </ComputeScalar>

    </RelOp>

    </Top>

    </RelOp>

    </QueryPlan>

    </StmtSimple>

    </Statements>

    </Batch>

    </BatchSequence>

    </ShowPlanXML>

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply