Numerator/Denominator

  • should be a simple solution for a non newby! Have separate queries for the numerator and denominator. Just trying to combine the two so the numerator and denominator are on the same row for each DivisionGroup

    DivisionGroup A, Numerator, Denominator

    DivisionGroup B, Numerator, Denominator

    Numerator code:

    SELECT IR.DivisionGroup, COUNT(PatientKey)as Count

    FROM [Quality].[dbo].[InpatientReadmissions] IR

    where(IR.ReAdmission30Days = '1')

    and(IR.DischargeDateTime >'2011-10-01' and IR.DischargeDateTime<'2012-08-01')

    and (IR.PlannedReadmission = '0')

    and (IR.PrincipleDxInitial in

    ('481','485','486','482.0','482.1','482.2','482.9','483.0','483.1','483.8'

    ,'487.0','482.30','482.31','482.32','482.39','482.40','482.41','482.42'

    ,'482.49','482.81','482.82','482.83','482.84','482.89'))

    group by [DivisionGroup]

    Denominator code:

    SELECT IR.DivisionGroup, count(readmissiondenom) as ReadDenom

    FROM [Quality].[dbo].[InpatientReadmissions] IR

    where (IR.DischargeDateTime >'2011-10-01' and IR.DischargeDateTime<'2012-08-01')

    --and (IR.PlannedReadmission = '0')

    and (IR.PrincipleDxInitial in

    ('481','485','486','482.0','482.1','482.2','482.9','483.0','483.1','483.8'

    ,'487.0','482.30','482.31','482.32','482.39','482.40','482.41','482.42'

    ,'482.49','482.81','482.82','482.83','482.84','482.89'))

    group by [DivisionGroup]

  • Could you do something like:

    ;WITH CTE_Numerator (DivisionGroup, NumCnt) AS

    (

    SELECT IR.DivisionGroup, COUNT(PatientKey)as Count

    FROM [Quality].[dbo].[InpatientReadmissions] IR

    WHERE (IR.ReAdmission30Days = '1')

    AND (IR.DischargeDateTime >'2011-10-01' and IR.DischargeDateTime<'2012-08-01')

    AND (IR.PlannedReadmission = '0')

    AND (IR.PrincipleDxInitial IN

    ('481','485','486','482.0','482.1','482.2','482.9','483.0','483.1','483.8'

    ,'487.0','482.30','482.31','482.32','482.39','482.40','482.41','482.42'

    ,'482.49','482.81','482.82','482.83','482.84','482.89'))

    GROUP BY [DivisionGroup]

    ),

    CTE_Denominator (DivisionGroup, DenomCnt) AS

    (

    SELECT IR.DivisionGroup, COUNT(readmissiondenom) as ReadDenom

    FROM [Quality].[dbo].[InpatientReadmissions] IR

    WHERE (IR.DischargeDateTime >'2011-10-01' and IR.DischargeDateTime<'2012-08-01')

    AND (IR.PrincipleDxInitial IN

    ('481','485','486','482.0','482.1','482.2','482.9','483.0','483.1','483.8'

    ,'487.0','482.30','482.31','482.32','482.39','482.40','482.41','482.42'

    ,'482.49','482.81','482.82','482.83','482.84','482.89'))

    GROUP BY [DivisionGroup]

    )

    SELECT a.DivisionGroup,

    a.NumCnt AS Numerator,

    b.DenomCnt AS Denominator

    FROM CTE_Numerator a

    LEFT JOIN CTE_Denominator b ON a.DivisionGroup = b.DivisionGroup;

    HTH,

    Rob

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

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