I have:SELECT YEAR(CREATEDDATETIME) AS Year, SUM(LINEAMOUNTMST) AS Turnover, SUM(UNITIES) AS QTY, SUM(COSTE) AS CostFROM dbo.WIKA_ES_UniversalGROUP BY YEAR(CREATEDDATETIME)
how do I get the margin (Turnover - Cost)/Turnover * 100 ?CASE WHEN LINEAMOUNTMST <> '0' THEN SUM((LINEAMOUNTMST - COSTE) / LINEAMOUNTMST * 100) ELSE '0' END AS Margin
doesn't give the correct result... beside the fact that this requires to group by LINEAMOUNTMST which does not make sense. And to make it even worse I get a zero devision too???Regards, Martin