Oracle NVL Functions

Source: Internet
Author: User

When I was working on a project recently, the customer had a need to fill in a few columns of the data queried from the database with a specific content, and use the NVL function to implement this function

The following is transferred from: https://www.cnblogs.com/yhoralce/p/6872121.html

Returns a non-null value from two expressions.

Grammar

NVL (EExpression1, EExpression2)

Parameters
EExpression1, EExpression2

If the eExpression1 evaluates to a null value, NVL () returns EEXPRESSION2. If the EExpression1 evaluates to a value other than NULL, the EExpression1 is returned. EExpression1 and EExpression2 can be any data type. If the result of both EExpression1 and EExpression2 is null, then NVL () returns. 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 parameter types to match

1SELECTT.d_fdate,2T.vc_zhcode,3 NVL (SUM (T.f_fzqsz),0) F_price_b,4 NVL (SUM (T.F_FZQCB),0) F_cost_b,5 NVL (SUM (T.F_FGZ_ZZ),0) F_gz_b,  6 NVL (sum (T.f_fyzqsz), 0) f_price_y, 7 NVL (sum (T.F_FYZQCB), 0) f_ Cost_y, 8 NVL (sum (t.f_fygz_zz), 0) f_gz_y, 9  T.vc_source,10  Sysdate D_ Updatetime11 from gz_fund_gzb T     

Such a judgment is important, because you do not know which line is not NULL, and do not know whether to perform operations on the cell next, so you can not fill the column with null, give it a 0, easy to view, but also easy to calculate.

Oracle NVL Functions

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.