WHERE MEASUREid='BP' and submeasure='TOT'
and plancode in ('QMX','QM') --these plancodes mapped to Reporting population='MEDCAD'
OR MEC2 LIKE '6757%' OR PayerCode = 'KD'
Tried below query.i dont think this is perfect way of writing ,eventhough its matching..
i have varous reporting population and based on the reporting population i need to join the columns
select dISTINCT a.*
from [##mi] AS A
left join qm.tbl_qsi_plan_to_RP(nolock) as b
when 'NCQA' then A.plancode
(Case ReportingPopulationName when 'NCQA' then A.PayerCode end )='KD'
(Case ReportingPopulationName when 'NCQA' then a.MEC2 end ) LIKE '6757%'
WHERE A.[PLAN]='MI' AND MEASUREid='BP' and submeasure='TOT' AND B.Market IS NOT NULL