The Oracle NVL () function handles null values

Source: Internet
Author: User

First I say what is Oracle's function, once a Daniel, let me talk about the familiar Oracle function, I was confused, thought "What Oracle function Ah, is not those SQL statements," then I actually uttered a select answer, he almost angry, Repeatedly stressed: "I said is the Oracle function", later he said, function can be understood as with parentheses (), then I slowly sensible after, often Baidu Oracle function, every time there is an interview or review, I have deliberately practiced SQL function.

Use the NVL function to handle null values:

Eg: Calculates the annual income of each person including monthly and year-end allowances

(1) Annual salary is (monthly) *12+ performance;

(2) but performance (comm) has a null value, and when Comm is a null value, the result of the monthly + performance is also a null value;

(3) So, when Comm is a null value, it needs to be treated as a zero. Which function can win this task? NVL ();

(4) NVL () is equivalent to an IF. Else statement, if the field is not empty, take the original value;

Select Ename,sal*12 +NVL (comm,0) as annual salary from EMP;

The Oracle NVL () function handles null values

Related Article

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.