Oracle’s NULLIF function


NULLIF(expression1,expression2)

–ORACLE’s NULLIF function returns a NULL value if two expressions are equal
–otherwise expression1 is returned
–expression1 and expresion2 must have the same data types

example

–returns NULL if two expressions are equal
–I mean if max-salary – min_salary is 3000 then NULLIF returns NULL
–otherwise (max_salary- min_salary) result will return from the function

SELECT NULLIF((max_salary- min_salary), 3000)
FROM  jobs
WHERE max_salary < 10000;

NULLIF((MAX_SALARY-MIN_SALARY),3000)
————————————
NULL–max_salary and min_salary difference is 3000 here
4800
4800
NULL –max_salary and min_salary difference is 3000 here
NULL –max_salary and min_salary difference is 3000 here
NULL –max_salary and min_salary difference is 3000 here
NULL –max_salary and min_salary difference is 3000 here
5000
5000

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s