Case... whenConditional Conversion Functions CaseWhen there are two forms of expression1 CaseVariable whenValue 1 ThenResults 1 whenValue 2 ThenResults 2Else 'other' End --else you can choose not toExample:SelectEname,job, ( CaseJob when 'MANAGER' ThenJob when 'Clerk' ThenJobEnd) fromEMP; 2 Case whenExpression 1 ThenResults 1 whenExpression 2 ThenResults 2Else 'other' EndExample:SelectEname,sal, Case whenDeptno=Ten Then 'Accounting Department' whenDeptno= - Then 'Research Department' whenDeptno= - Then 'Sales Department' Else 'other Departments' End fromEMP;--after the current face condition is filtered in case, it is then extracted from the rest of the previous data. --take the EMP table below the Scott user as an example. --The order of the second method needs to be taken into account. Sql> SelectT.*, Case whenT.sal>= the Then '[' 2 whenT.sal< the andT.sal>=2500 Then '[2500-3000' 3 whenT.sal<2500 andT.sal>= the Then '[1500-2500' 4 Else '<1500' End asSal_level5, Case whenT.sal>= the Then '[' 6 whenT.sal>=2500 Then '[2500-3000' 7 whenT.sal>= the Then '[1500-2500' 8 Else '<1500' End assal_level_test9 fromEMP T; EMPNO ename JOB MGR hiredate SAL COMM DEPTNO sal_level sal_level_test----- ---------- --------- ----- ----------- --------- --------- ------ ---------- -------------- 7369SMITH Clerk7902 1980/ A/ - 800.00 - < the < the 7499ALLEN salesman7698 1981/2/ - 1600.00 300.00 - [1500-2500 [1500-2500 7521 WARD salesman 7698 1981/2/22 1250.00 500.00-<1500 <1500 7566 JO NES MANAGER 7839 1981/4/2 2975.00 [2500-3000 [2500-3000 7654 MARTIN salesman 7698 1981 /9/28 1250.00 1400.00 <1500 <1500 7698 BLAKE MANAGER 7839 1981/5/1 2850.00 [2500-3000 [2500-3000 7782 CLARK MANAGER 7839 1981/6/9 2450.00 10 [1500-2500 [1500-2500] 7788 SCOTT ANALYST 7566 1987/4/19 3000.00 [[7839] KING President 19 81/11/17 5000.00 [7844 TURNER salesman 7698 1981/9/8 1500.00 0.00 [1500-2500 [1500-2500 7876 ADAMS clerk 7788 1987/5/23 1100.00 <1500 <1500 790 0 JAMES Clerk 7698 1981/12/3 950.00 <1500 <1500 7902 FORD ANALYST 7566 1981/12/3 on 3000.00 [7934 MILLER clerk 7782 1982/1/23 1300.00 <1500 < 1500
When using case in Oracle