0
Sql Serverを使用しています: このID(MrHCClaim_id
)がこの一連の基準に含まれている場所を探していますが、 。基本的に、データの行が1つしかないIDを探します。ここでIDはパラメータのセットであり、その他の場所はありません(1行のデータ)
:
select MrHcClaim_id, HospCd, PyrNm, payor, PatNo, SvDate,
sum(case when HcPcS in ('99211', '99212', '99213', '99214', '99215')
and SvMod like '%25%'
then cast(units as decimal) else 0 end) as "E&M25s",
sum(cast (units as decimal)) as "units"
from MrHcClaim as a
left join MrHcClaimDtl as c
on a.MrHcClaim_id = c.MrHcClaimDtl_id
where SvDate between '11/01/2016'
and '11/30/2016'
and payor = '1'
and (billstatus = 't' or billstatus = 'p')
and hospcd <> 'saltzer'
group by MrHcClaim_id, HospCd, PyrNm, payor, PatNo, SvDate
having sum(case when HcPcS in ('99211', '99212', '99213', '99214', '99215')
and svmod like '%25%'
then cast(units as decimal) else 0 end) > 0
and sum(cast(units as decimal)) = sum(case when hcpcs in
('99211', '99212', '99213', '99214', '99215')
and svmod like '%25%' then units else 0 end)
サンプルデータと期待される出力が役立ちます – artm