Interval usage of oracle:case when statements

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.