today:
42
yesterday:
46
Total:
998,741

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
66 INSERT PROCESS admin 2016.04.28 159
65 TAP ( Main & Sub ) / Button 의 Switch admin 2016.04.28 158
64 Delete Message - Are you sure you want to delete this object? admin 2016.04.28 158
63 DELETE PROCESS admin 2016.04.28 157
62 SQL Developer Password change / EXPORT & IMPORT admin 2022.03.18 157
61 JAVA for delete admin 2016.04.28 154
60 MAX admin 2016.04.28 154
59 PHONE NUMBER admin 2016.04.28 152
58 Forgot Oracle username and password, how to retrieve? admin 2022.03.18 151
» NVL admin 2016.05.19 151
56 CREATE (INSERT) PROCESS admin 2016.04.28 150
55 Field Showing admin 2016.04.01 148
54 wwv_flow_files admin 2016.05.01 147
53 Outer Join with Oracle SQL admin 2016.04.29 147
52 COUNT admin 2016.04.28 145
51 BOOLEAN SAMPLE admin 2016.05.11 144
50 How to Update Oracle XE admin 2018.04.25 137
49 APEX Connect 2016 - David Peake - New Features in Oracle Application Express 5.1 admin 2017.11.25 134
48 Delimiter admin 2016.04.29 133
47 HEAD TITLE (제목)을 조건에 따라 바꾸기 admin 2016.05.03 132