Home > database >  New questions and doubts about case when statement
New questions and doubts about case when statement

Time:10-12



My statement:
Select deptno, job, avg (sal), avg (NVL (comm, 0))
Case avg (NVL (comm, 0))
The when avg (NVL (comm, 0)) & gt; 300 then 'bonus is good'
The when avg (NVL (comm, 0)) & gt; 100 and avg (NVL (comm, 0)) & lt; 300 then 'bonuses generally'
The when avg (NVL (comm, 0)) & lt; 100 then 'basic no bonus'
The else
End commstatus,
Group by deptno, job
The order by the deptno desc, job desc;

System tip: in line 3 & gt; Below a *, command not correct end

For everyone a great god grant instruction, thank you very much!!!!!

CodePudding user response:

Case behind the average can be removed, and then the else need to give a value or end directly

CodePudding user response:

Select deptno, job, avg (sal), avg (NVL (comm, 0))
Case
The when avg (NVL (comm, 0)) & gt; 300 then 'bonus is good'
The when avg (NVL (comm, 0)) & gt; 100 and avg (NVL (comm, 0)) & lt; 300 then 'bonuses generally'
The when avg (NVL (comm, 0)) & lt; 100 then 'basic no bonus'
End commstatus,
Group by deptno, job
The order by the deptno desc, job desc;

CodePudding user response:

Thank you very much thank you very much!!!!!!
  • Related