amolik
09-20-2003, 05:42 AM
Hi All
after searching a lot for comparing two values in SQL I found a query in one forum which was unusual and also give error.
-------------------
select sum(case when sal < 0 then sal end) neg ,
sum(case when sal > 0 then sal end) pos
from emp
/
select sum(case when sal < 0 then sal end) neg ,
*
ERROR at line 1:
ORA-00907: missing right parenthesis
-------------------
I havent seen 'case' statement in simple SQL before and also 'when' and 'then'. Is there any new development in Oracle latest versions. I guess you all can enlighten on this. Also is there any function like above to compare values in Simple SQL.
Amol
after searching a lot for comparing two values in SQL I found a query in one forum which was unusual and also give error.
-------------------
select sum(case when sal < 0 then sal end) neg ,
sum(case when sal > 0 then sal end) pos
from emp
/
select sum(case when sal < 0 then sal end) neg ,
*
ERROR at line 1:
ORA-00907: missing right parenthesis
-------------------
I havent seen 'case' statement in simple SQL before and also 'when' and 'then'. Is there any new development in Oracle latest versions. I guess you all can enlighten on this. Also is there any function like above to compare values in Simple SQL.
Amol