SQL NULLIF Function

What is the use of NULLIF function in SQL?

Questions by Subashpanda   answers by Subashpanda

Showing Answers 1 - 2 of 2 Answers

Prem_p

  • Apr 28th, 2011
 

In SQL, NullIf function is used to compare two expressions. There are 3 possible results for NULLIF.

1. If the values are same, NullIf returns NULL. Eg: NULLIF('Prem','Prem') returns NULL
2. If they are not, it'll return the first value. Eg : NULLIF(1,5) returns 1
3. If the first exp is NULL, return error -> ORA-00932 : Eg : NULLIF(NULL,'Oracle') return error.

Whatever exp you compare, both of them should have the same datatype. Otherwise it's an error.

  Was this answer useful?  Yes

sampra

  • Mar 6th, 2012
 

In SQL, NullIf function is used to compare two expressions. There are 3 possible results for NULLIF.

1. If the values are same, NullIf returns NULL. Eg: NULLIF(Prem,Prem) returns NULL

2. If they are not, itll return the first value. Eg : NULLIF(1,5) returns 1

3. If the first exp is NULL, return error -> ORA-00932 : Eg : NULLIF(NULL,Oracle) return error.

Whatever exp you compare, both of them should have the same datatype. Otherwise its an error.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions