Protected by Copyscape Web Copyright Protection Software

Pages

Search This Blog

Tuesday, March 11, 2014

Case Example

Simple Example of CASE in SQL

SELECT e.empno
      ,e.ename
      ,e.sal
      , CASE WHEN e.sal BETWEEN -999999 and -1 THEN 'Z'
             WHEN e.sal BETWEEN 0 and 1000 THEN 'E'
             WHEN e.sal BETWEEN 1001 and 5000 THEN 'D'
             WHEN e.sal BETWEEN 5001 and 10000 THEN 'C'
             WHEN e.sal BETWEEN 10001 and 20000 THEN 'B'
             ELSE 'A'
        END grade
 FROM emp e
 ORDER BY 4;

For any Queries contact:  kommarajashekarreddy@gmail.com

No comments:

Post a Comment