Hi, I must use conditions in my SQL statement. Please tell me: can I use sum() funtion within CASE WHEN clause? Example below.
Thanks for help !
Code:
select x, sum(y) from ( select a.xxx A, a.yyy B, b.xxx C, b.yyy D, case (b.zzz) when b.yyy > 0 then (a.yyy / a.xxx) when b.yyy < 0 then (a.yyy * a.xxx) when b.yyy = 0 then sum(a.yyy + sum(100/(100*a.yyy))) <---- I need to do such thing with sum(), is it possible to make in SQL in DB2? end as Var from table1 a, table2 b where a.xxx = b.yyy ) as temp where A > 0 group by x





Comment