Solved

# Cannot perform an aggregate function on an expression containing an aggregate or a subquery

Posted on 2008-10-02

(SUM(CASE WHEN ha.AllowanceCode IN('100','130','AL','BL','BL1','DL','JS','LD','LSL','MU','NWA1','SP','R','SL','SSL','ST','TOILT') THEN ha.FTEhours /

(case when e.employeecode = '1011' and count(distinct tpps.sequencenumber) = 2 then 180

when e.employeecode = '1011' and count(distinct tpps.sequencenumber) = 3 then 270

when e.employeecode <> '1011' and count(distinct tpps.sequencenumber) = 2 then 160

when e.employeecode <> '1011' and count(distinct tpps.sequencenumber) = 3 then 240 end)

ELSE

CASE WHEN ha.AllowanceCode IN('120', '150','ACC','ACC1','AOT','LN','NWA') THEN ha.Quantity /

(case when e.employeecode = '1011' and count(distinct tpps.sequencenumber) = 2 then 180

when e.employeecode = '1011' and count(distinct tpps.sequencenumber) = 3 then 270

when e.employeecode <> '1011' and count(distinct tpps.sequencenumber) = 2 then 160

when e.employeecode <> '1011' and count(distinct tpps.sequencenumber) = 3 then 240 end)

ELSE 0 END

END

) AS [Month]

Any other way around this?

How else can I get the value to the right of the "/"