and now I need to create a query that sum the value of (1+3+(5/ 2)) and (2+4+(5/ 2))

here is my query:

SELECT process_id, compound_type, CASE WHEN (shift_id IS NOT NULL AND (shift_id = 1 OR shift_id = 3 OR shift_id = 5))
THEN SUM((compound_output)/2)
when (shift_id IS NOT NULL AND (shift_id = 2 OR shift_id = 4 OR shift_id = 5))
THEN SUM((compound_output)/2) END AS val
FROM op_output WHERE process_id = 7 and compound_type = 'P28' HAVING val IS NOT NULL

and the output of this is:

val = 47.500000

but it should be:7---P28--307---P28--65

Thank you so much..

I hope somebody can help me to get the correct values.

Thank you so much.

r937
—
2013-07-10T08:09:18Z —
#2

SUM() is an aggregate function and won't work without a GROUP BY clause

look at your two THEN results... they are the same, so you don't really need a CASE at all