I have the following SQL Query:
SELECT
a.IA
, a.PC
, a.LC
, a.CXPevalCnt
, ((a.IA / nullif(a.CXPevalCnt,0))*0.35) as IAcalc
, ((a.LC / nullif(a.CXPevalCnt,0))*0.5) as legacalc
, ((a.PC / nullif(a.CXPevalCnt,0))*0.15) as pccalc
, (
((a.IA / nullif(a.CXPevalCnt,0))*0.35)
+ ((a.LC / nullif(a.CXPevalCnt,0))*0.5)
+ ((a.PC / nullif(a.CXPevalCnt,0))*0.15)
) as Compliance
FROM
(
SELECT
SUM(IA) as IA
, SUM(PC) as PC
, SUM(LC) as LC
, SUM(CXPevalcount) as CXPevalCnt
FROM
tblPLOps_Data
) as A
Which returns the following data:
IA PC LC CXPevalCnt IAcalc legacalc pccalc Compliance
15 12 15 15 0.35 0.5 0 0.85
If PC is 12 and CXPevlacnt is 15 I cannot figure out why in my query when I add them together cxpevalcount nulls out but only for PC and not when used with IA or LC. I have sliced this query many different ways and can't figure out the issue
any ideas?