In the practice case when the statement, encountered an example, the result of the answer is not correct, the syntax will not pass, began to think is not a case can only be a fixed value, after all, the example given is a fixed value, after a long time on the Internet to find the use of the interval, the following examples
Background is the EMP table below the Scott user (the default comes with Oracle creation)
Work out each department, average salary for each post and mean bonus (average includes no bonuses) if the average bonus is greater than 300, show ' bonus good ', if the average bonus is 100 to 300, show ' bonus generally ', if the average bonus is less than 100, show "Basic No Bonus", by sector number descending, Average wage descending rank select deptno,job,avg (sal) median salary, avg (NVL (comm,0)) Avg Bonus, case when AVG (NVL (comm,0)) >=300 Then ' bonus good 'avg (NVL (comm,0)) >100 and avg (NVL (comm,0)) <300 Then ' Bonus General ' else ' basic no bonus ' end bonus status from EMP Group by Deptno,jo b ORDER BY deptno DESC, avg (SAL) desc; That is, there is no need to take parameters before and after the case, in the when to bring the parameters into
Interval usage of oracle:case when statements