today:
39
yesterday:
158
Total:
1,001,293

SQL NVL

admin 2016.05.19 15:08 Views : 151

NVL

Syntax

Description of nvl.gif follows
Description of the illustration nvl.gif

Purpose

NVL lets you replace null (returned as a blank) with a string in the results of a query. If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL returns expr1.

The arguments expr1 and expr2 can have any datatype. If their datatypes are different, then Oracle Database implicitly converts one to the other. If they are cannot be converted implicitly, the database returns an error. The implicit conversion is implemented as follows:

  • If expr1 is character data, then Oracle Database converts expr2 to the datatype of expr1 before comparing them and returns VARCHAR2 in the character set of expr1.

  • If expr1 is numeric, then Oracle determines which argument has the highest numeric precedence, implicitly converts the other argument to that datatype, and returns that datatype.

    See Also:

    Table 2-10, "Implicit Type Conversion Matrix" for more information on implicit conversion and "Numeric Precedence" for information on numeric precedence

Examples

The following example returns a list of employee names and commissions, substituting "Not Applicable" if the employee receives no commission:

SELECT last_name, NVL(TO_CHAR(commission_pct), 'Not Applicable')
   "COMMISSION" FROM employees
   WHERE last_name LIKE 'B%'
   ORDER BY last_name;
 
LAST_NAME                 COMMISSION
------------------------- ----------------------------------------
Baer                      Not Applicable
Baida                     Not Applicable
Banda                     .1
Bates                     .15
Bell                      Not Applicable
Bernstein                 .25
Bissot                    Not Applicable
Bloom                     .2
Bull                      Not Applicable
No. Subject Author Date Views
46 Oracle APEX 5.1.4 Installation admin 2018.04.17 132
45 HEAD TITLE (제목)을 조건에 따라 바꾸기 admin 2016.05.03 132
44 Column Data 일괄 추가 admin 2023.11.24 130
43 Global & Custom Serach file admin 2016.04.28 127
42 LIST OF VALUE (DYNAMIC) admin 2016.04.28 126
41 What Is ERP? admin 2018.02.14 121
40 test admin 2016.05.11 121
39 Oracle SQL Developer: Online Migration 3.1 admin 2018.04.25 120
38 How to Install Oracle 11g on Windows 10 - 64 bit | Download / Install Oracle 11g Database file admin 2022.03.17 120
37 Interactive Report admin 2016.05.07 116
36 LAST DAY SQL admin 2024.01.19 115
35 Display Value, Return Value admin 2016.05.10 115
34 Null Display Value admin 2024.01.10 111
33 QR-CODE admin 2017.11.30 111
32 APEX ADMIN PASSWORD 바꾸기 admin 2016.05.02 108
31 SQL DEVELOPER file admin 2022.03.17 106
30 TEST admin 2023.03.27 97
29 SQL Basics - Lesson 1 - Introduction admin 2017.06.17 97
28 image (products) admin 2017.11.24 92
27 Material requirements planning (MRP) admin 2018.02.14 88