Hey guys...this may seem trivial but I've been up way too long today and I just can't wrap my head around it. I need conditional summation performed based on a given value. For instance:
It doesn't seem to like the sum of the case statement stuff. Says an error in my syntax near ') AS 'total'. This is probably very true..I just don't see it. Sorry to bother...thanks in advance.
Code:
SELECT SUM(CASE WHEN tbl_a.aID = 1
THEN SUM( crazy math goes here )
ELSE WHEN tbl_a.aID = 2
THEN SUM( crazy math goes here )
ELSE 0
END) AS 'total', MONTHNAME( tbl_a.field2 )
FROM tbl_a
It doesn't seem to like the sum of the case statement stuff. Says an error in my syntax near ') AS 'total'. This is probably very true..I just don't see it. Sorry to bother...thanks in advance.