UPDATE a set a.YC_AMT = b.YC_AMT
from
MS_AssociatorlFValue a
join (
select top 1 a.bill_id bill_id,(
select SUM(YC_AMT) from MS_Associatorl
where ASSOCIATORL_ID IN (
select ASSOCIATORL_ID from MS_AssociatorlHBDetail where SERVICEITEM_ID = 5067 AND
BILL_ID IN (
select BILL_ID from MS_AssociatorlFValue where ASSOCIATORL_ID =
(
select ASSOCIATORL_ID from MS_Associatorl where ASSOCIATORL_NO = '015391' --替换会员卡号
)
)
)
)YC_AMT
FROM MS_AssociatorlFValue a join MS_AssociatorlHBDetail b on(a.BILL_ID = b.BILL_ID) where b.SERVICEITEM_ID = 5067 and a.ASSOCIATORL_ID = (
select ASSOCIATORL_ID from MS_Associatorl where ASSOCIATORL_NO = '015391'--替换会员卡号
)
)
b on(a.bill_id = b.bill_id)