i was asked in an interview to use the decode function to print High if salary was greater than 2500 and low if it was less than 2000... but i dont know how to use relational operators in decode ??!! is that possible ?? help plz
DECODE function
Collapse
X
-
-
DECODE is a power function, and that was a trick question.
Here are some details on DECODE on this link.
http://www.psoug.org/reference/decode_case.htm lComment
-
Use case within Decode
Since Expressions can't be used with decode
The output of case should be input for decode.
U can also do it using only CASE, no need of decode at all.
Code:SELECT decode( CASE WHEN sal>2500 THEN '1' WHEN sal<2000 THEN '2' END ,'1','High','2','Lo') FROM EMP
Comment
-
Originally posted by jessyi was asked in an interview to use the decode function to print High if salary was greater than 2500 and low if it was less than 2000... but i dont know how to use relational operators in decode ??!! is that possible ?? help plz
As per the requirement, below script will print
Low for <2000
High for>2500
but null for 2000 to 2500
select decode(least(&s alary,2000),200 0,decode(greate st(&salary,2500 ),&salary,'High '),'Low') print from dualComment
Comment