NVL Function in SQL Query

NVL Function in SQL Query

WingsOfTechnology

1 десятилетие назад

7,297 Просмотров

NVL():
The Oracle/PLSQL NVL function lets you substitute a value when a null value is encountered.
Syntax:
NVL( string1, replace_with )
Arguments:
string1 is the string to test for a null value.
replace_with is the value returned if string1 is null.
Example:
Let's look at some Oracle NVL function examples and explore how you would use the NVL function in Oracle/PLSQL.

For example:

select NVL(comm, 'n/a') from emp;
The SQL statement above would return 'n/a' if the 'comm' field contained a null value. Otherwise, it would return the 'comm' value.



Lets have a look on emp table. Here for manager and comm columns we have null data. In output, I am getting null values. By using NVL function i can omit these null values in output.

Тэги:

#SQL_(Programming_Language) #Oracle #SQL_Developer #developer #SQL #PL/SQL #sql #query_language #oracle_tables #table_in_database #database_table #functions_in_oracle #oracle_SQL_Developer #NVL_Function_in_SQL_Query #NVL_Function #NVL_Function_in_SQL #NVL() #NVL_function #null_to_value #nvl()
Ссылки и html тэги не поддерживаются


Комментарии: