我有这个代码
Select proinfo.ProjectN AS 'BS',
proinfo.Weight AS 'Poids Dossier Kg',
Cast((SUM(Case when DailyFab.FK_idNextProcess=13
then ProjShFab.[Weight] * DailyFab.[Quantity] Else 0 End)/proinfo.Weight)*100 as decimal(10,2)) as 'Taux Fab',
Cast((SUM(Case when DailyShipp.FK_idNextProcess=14
then ProjShFab.[Weight] * DailyShipp.[Quantity] Else 0 End)/proinfo.Weight)*100 as decimal(10,2)) as 'Taux Exp'
FROM
[dbo].[ProjectShipping] ProjShFab
Inner JOIN ProjectInfo proinfo ON proinfo.id = ProjShFab.IdProject
Left Join DailyShippingSteelNavision DailyShipp on DailyShipp.FK_idPartShip= ProjShFab.id
Left Join DailyPaintProduction DailyFab on DailyFab.FK_idPartShip= ProjShFab.id
Group By proinfo.ProjectN,proinfo.Weight
Order by proinfo.ProjectN
当我运行它时,我在“ Taux Fab”和“ Taux Exp”中都得到了不正确的值,但是假设我注释了这行代码
--Left Join DailyPaintProduction DailyFab on DailyFab.FK_idPartShip= ProjShFab.id
然后我运行代码,在“ Taux Exp”中获得正确的值,反之亦然 我为什么会有这个问题,以及如何解决这个问题,请先谢谢。