NVL () function in Oracle

Source: Internet
Author: User

NVL () function in Oracle
How Oracle's NVL function is used


The total value of a field is obtained by querying, assuming that the value bit null will give a preset default value
Select NVL (SUM (T.DWXHL), 1) from Tb_jhde t where zydm=-1
Here the Nvl method of Use, NVL (Arg,value) represents the assumption that the value of the preceding ARG is NULL then the returned value is
For example, NVL (A, A, b) is to infer whether a is null, assuming that the value of a is not returned. Suppose that the value of return B is obtained by querying the total value of a field, assuming that the value bit null will give a default value of a preset


There is also a practical way to
Declare
I integer
Select NVL (SUM (T.DWXHL), 1) into I from Tb_jhde t where zydm=-1
This allows you to store the obtained aggregate values in the variable i. Assuming that the value of the query is NULL, set its value to the default of 1


The Oracle lower NVL function NVL () function returns a non-null value from two expressions.
Grammar
NVL (EExpression1, EExpression2)
Number of references
EExpression1, EExpression2
If the eExpression1 evaluates to a null value. Then NVL () returns EEXPRESSION2. Assume that EExpression1 evaluates to a value other than null. The EExpression1 is returned. EExpression1 and EExpression2 can be arbitrary data types. Assuming that the result of both EExpression1 and eExpression2 are null values, NVL () is returned. Null..


return value type
character, date, datetime, numeric, currency, logical, or null values
Description
You can use NVL () to remove null values from a calculation or operation in cases where null values are not supported or if NULL values do not matter.

Select NVL (a.name, ' empty ') as name from student a joins school B on a.id=b.id Note: Two number of types to match Q: What is NULL? A: When we do not know the details of what data, it is unknown, can be used null, we call it empty, Oracle, contains null values of the table column length is zero.
Oracle agrees that no field of a data type is empty. In addition to the following two scenarios:

NVL () function in Oracle

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.