SQL JOIN get incorrect value

Asked by At

I have this code

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 

when I run it I get incorrect value in both 'Taux Fab' and 'Taux Exp' but let's say i comment this line of code

--Left Join DailyPaintProduction DailyFab on DailyFab.FK_idPartShip= ProjShFab.id

then I run the code I get the correct value in 'Taux Exp' and verse versa Why am I having this problem and how can I solve it, thanks in advance.

0 Answers