Oracle9i SQL Reference Release 1 (9.0.1) Part Number A90125-01 |
|
Functions, 83 of 166
nullif::=
nullif
The NULLIF
function compares expr1 and expr2. If they are equal, the function returns null. If they are not equal, the function returns expr1. You cannot specify the literal NULL
for expr1.
The NULLIF
function is logically equivalent to the following CASE
expression:
CASE WHEN expr1 = expr 2 THEN NULL ELSE expr1 END
The following example selects those employees from the sample schema hr
who have changed jobs since they were hired, as indicated by a job_id
in the job_history
table different from the current job_id
in the employees
table:
SELECT e.last_name, NULLIF(e.job_id, j.job_id) "Old Job ID" FROM employees e, job_history j WHERE e.employee_id = j.employee_id; LAST_NAME Old Job ID ------------------------- ---------- De Haan AD_VP Kochhar AD_VP Kochhar AD_VP Hartstein MK_MAN Raphaely PU_MAN Kaufling ST_MAN Whalen Taylor Taylor SA_REP Whalen AD_ASST
|
![]() Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|