我正在使用来自多个表的值更新表。
UPDATE pv SET
pv.[TotalDInTCG] = Dr.TCGDCnt
,pv.[AvgHbA1cImprovement] = hsd.AvgHbA1cCnt
,pv.[TotalCHDInTCG] = cpc.CHdCnt
,pv.[TotalCHDNTCG] = cpd1.CHdWithCholBPCnt
,pv.[PercentageOfCHDWithBPChol] = icp.CHFElligPopul
,pv.[TotalCOPDInTCG] = copd.TcgCOPDcount
,pv.[TotalCOPDMRCPOxySatuLevel] = copdmrc.TotalCOLevel
,pv.[PercentOferTCG] = copdOxSatu.oxySatligPopu
FROM #tmpeTabel AS pv
INNER JOIN #DRegistered AS Dr
ON Dr.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND Dr.Years = pv.[ReportYear]
AND Dr.Months = pv.[ReportMonth]
INNER JOIN #HbA1cScoreDetails AS hsd
ON hsd.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND hsd.Years = pv.[ReportYear]
AND hsd.Months = pv.[ReportMonth]
INNER JOIN #CHDCount as cpc
ON cpc.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND cpc.Years = pv.[ReportYear]
AND cpc.Months = pv.[ReportMonth]
INNER JOIN #CHDBPCholPatientsDetails as cpd1
ON cpd1.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND cpd1.Years = pv.[ReportYear]
AND cpd1.Months = pv.[ReportMonth]
INNER JOIN #ImprovementCHFPerPractice as icp
ON icp.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND icp.Years = pv.[ReportYear]
AND icp.Months = pv.[ReportMonth]
INNER JOIN #COPDCount as copd
ON copd.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND copd.Years = pv.[ReportYear]
AND copd.Months = pv.[ReportMonth]
INNER JOIN #COPDDetailsMRCOxygenSatuLevel as copdmrc
ON copdmrc.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND copdmrc.Years = pv.[ReportYear]
AND copdmrc.Months = pv.[ReportMonth]
INNER JOIN #ImprovPerElligPopula as copdOxSatu
ON copdOxSatu.SK_ServiceProviderID = pv.SK_ServiceProviderID
AND copdOxSatu.Years = pv.[ReportYear]
AND copdOxSatu.Months = pv.[ReportMonth]
这里的问题是,有些表有很多行,而有些表有更少的行。但是我在更新后得到的每张表的行数都变少了
我应该为每个选择表单独使用更新..