Update BS_Storage set StoreQty = StoreQty-a.mQty from(
select NB_DisBill.companyId,goodsId,NB_DisBill.OutStoreId,OutStorePos,mQty,
NB_DisBill.billNo from NB_DisBill
inner join NB_DisBillDetail on NB_DisBill.companyId = NB_DisBillDetail.companyId
and NB_DisBill.billNo = NB_DisBillDetail.billNo
) as a where a.companyId = BS_Storage.companyId and a.goodsId = BS_Storage.goodsId
and a.OutStoreId = BS_Storage.StoreId and a.OutStorePos = BS_Storage.StorePos
and a.billNo = 'DB0706200024' and a.companyid = '002'
select NB_DisBill.companyId,goodsId,NB_DisBill.OutStoreId,OutStorePos,mQty,
NB_DisBill.billNo from NB_DisBill
inner join NB_DisBillDetail on NB_DisBill.companyId = NB_DisBillDetail.companyId
and NB_DisBill.billNo = NB_DisBillDetail.billNo
) as a where a.companyId = BS_Storage.companyId and a.goodsId = BS_Storage.goodsId
and a.OutStoreId = BS_Storage.StoreId and a.OutStorePos = BS_Storage.StorePos
and a.billNo = 'DB0706200024' and a.companyid = '002'