decode
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: decode

Hybrid View

  1. #1
    Join Date
    Feb 2001
    Posts
    103
    Hi friends,

    I though this might help all of us.
    If i want to write a if then elsif statement in single statement informing me that if my sal is less than 2000 it would give me high, if it is less than 2000 then low , if it is less then 1000 then low..

    I have written a select statement. I will be glad to have improvements on this select statement..

    SELECT EMPNO,SAL,DECODE(SIGN(SAL-2000),-1,(DECODE(SIGN(SAL-1000),1,'MIDDLE',-1,'LOW')),'HIGH') from emp..
    When the going gets tough, the tough gets going

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    try this
    SELECT empno, ename, job, sal,
    DECODE(SIGN(sal-2000),1,'HIGH',-1,'LOW',0,'MIDDLE')
    FROM emp;
    thnx,
    Cheers!
    OraKid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width