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

Published: 12 August 2023
on channel: ERP Scope
286
2

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:
   • How to install Oracle Sample Database sche...  

✅ How to become oracle expert atrical:
https://erpscope.com/how-to-become-or...

✅ linkedin :   / posts  

✅Facebook:   / erpscope  

✅ Twitter:   / erp_scope  

✅Instagram:   / erp_scope  

✅ Youtube:    / @erpscope  


On this page of the site you can watch the video online Oracle Sql NVL and NVL2 function - What is the Difference? [SQL tutorial] with a duration of hours minute second in good quality, which was uploaded by the user ERP Scope 12 August 2023, share the link with friends and acquaintances, this video has already been watched 286 times on youtube and it was liked by 2 viewers. Enjoy your viewing!