today:
0
yesterday:
150
Total:
996,795

SQL NVL

admin 2016.05.19 15:08 Views : 150

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
106 TEST admin 2023.04.28 40
105 WHDR email address admin 2023.04.13 55
104 TEST admin 2023.03.27 97
103 GP 영수증 (3) -01/04/2023 admin 2023.01.04 53
102 GP - 영수증 (2) admin 2022.11.07 63
101 GP 영수증 본문 admin 2022.11.07 61
100 STARTUP admin 2022.09.01 83
99 SQL Developer Password change / EXPORT & IMPORT admin 2022.03.18 157
98 Forgot Oracle username and password, how to retrieve? admin 2022.03.18 150
97 SQL DEVELOPER file admin 2022.03.17 106
96 How to Install Oracle 11g on Windows 10 - 64 bit | Download / Install Oracle 11g Database file admin 2022.03.17 120
95 QRCODE admin 2020.05.25 405
94 JK admin 2019.02.05 700
93 ACTION admin 2019.01.11 6454
92 SELECT last_name FROM admin 2018.12.12 742
91 IMP admin 2018.10.08 717
90 CREATE TABLE admin 2018.09.25 471
89 Change Admin PASSWORD admin 2018.07.31 225
88 VERY IMPORTANT admin 2018.06.26 224
87 IF/ELSE ... CASE WHEN admin 2018.06.25 208