Oracle9i SQL Reference
Release 1 (9.0.1)

Part Number A90125-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

Functions, 83 of 166


NULLIF

Syntax

nullif::=


Text description of functions131a.gif follows
Text description of nullif

Purpose

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

See Also:

"CASE Expressions" 

Example

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

Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback