Accenture Interview Questions | What is the use of NVL function in Oracle?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 2 )
The NVL() function lets you return an alternative value when an expression iS NULL.
The syntax is NVL(expr1,expr2).
Example:
SELECT ProductName, UnitPrice * (UnitsInStock + NVL(UnitsOnOrder, 0))
FROM Products;
The above query will return 0 when UnitsOnOrder is NULL.
.
The NVL function allows you to replace null values with a default value. If the value in the first parameter is null, the function returns the value in the second parameter.
e.g- select id, nvl(col_1, 0)
Whenever the col_1 is null, it will return its value as 0