Oracle Sql NVL and NVL2 function – What is the Difference? [SQL tutorial]



Oracle Sql NVL and NVL2 function – What is the Difference? [SQL tutorial]

Oracle Sql NVL and NVL2 function - What is the Difference? [SQL tutorial]

NVL and NVL function are a powerful functions in Oracle Sql,
you can use it to convert null values to whatever the values you need.
it will help you make calculations on Oracle database with more accurate results.

NVL Syntax:
===========
NVL (expr1, expr2)
You can use the NVL function to convert any data type, but the return value is always the same as the data type of expr1.

NVL2 Syntax:
===========
NVL2 (expr1, expr2, expr3)
The NVL2 function examines the first expression. If the first expression is not null, then the NVL2 function returns the second expression. If the first expression is null, then the third expression is returned.

NVL function example:
SELECT last_name, salary, NVL(commission_pct, 0),
(salary*12) + (salary*12*NVL(commission_pct, 0)) AN_SAL
FROM employees;

NVL2 function example:
SELECT last_name, salary, commission_pct,
NVL2(commission_pct,
‘SAL+COMM’, ‘SAL’) income
FROM employees WHERE department_id IN (50, 80);

Chapters:
0:00 Intro
0:25 NVL function Syntax.
1:08 NVL function example.
3:33 NVL2 function Syntax.
4:07 NVL2 function example.
6:30 How to install the same database on your machine.

✅ To install the same database in examples, please check this video:
https://youtu.be/j913y6CStoQ

✅ How to become oracle expert atrical:
https://erpscope.com/how-to-become-oracle-expert-developer-steps-to-start-your-career/

✅ linkedin : https://www.linkedin.com/company/96407286/admin/feed/posts/

✅Facebook: https://www.facebook.com/erpscope

✅ Twitter: https://twitter.com/erp_scope

✅Instagram: https://www.instagram.com/erp_scope/

✅ Youtube: https://www.youtube.com/channel/UCw9GwyflX_x6xxY94Xpqsdw

#sql #oracle #oraclereading #sql tutorials
#how to #oracle database