0
使用Sql服務器: 我想知道這個ID(MrHCClaim_id
)在這個標準集中的位置,但不屬於任何其他標準。基本上找到只有一行數據的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