case语句

SQL>   select ename,sal,
               case when sal <=2000 then 'UNDERPAID'
                    when sal >= 4000 then 'OVERPAID'
                    else 'OK'
       end as sal
      from emp;  2    3    4    5    6  

ENAME		  SAL SAL
---------- ---------- ---------
SMITH		  800 UNDERPAID
ALLEN		 1600 UNDERPAID
WARD		 1250 UNDERPAID
JONES		 2975 OK
MARTIN		 1250 UNDERPAID
BLAKE		 2850 OK
CLARK		 2450 OK
SCOTT		 1500 UNDERPAID
KING		 5000 OVERPAID
TURNER		 1500 UNDERPAID
ADAMS		 1100 UNDERPAID

ENAME		  SAL SAL
---------- ---------- ---------
JAMES		  950 UNDERPAID
FORD		 3000 OK
MILLER		 1300 UNDERPAID

14 rows selected.

你可能感兴趣的:(case语句)