What is difference between IIF and DECODE function

Showing Answers 1 - 5 of 5 Answers

VJ

  • Dec 16th, 2005
 

You can use nested IIF statements to test multiple conditions. The following example tests for various conditions and returns 0 if sales is zero or negative:

IIF( SALES > 0, IIF( SALES < 50, SALARY1, IIF( SALES < 100, SALARY2, IIF( SALES < 200, SALARY3, BONUS))), 0 )

You can use DECODE instead of IIF in many cases. DECODE may improve readability. The following shows how you can use DECODE instead of IIF :

   SALES > 0 and SALES < 50, SALARY1,

   SALES > 49 AND SALES < 100, SALARY2,

   SALES > 99 AND SALES < 200, SALARY3,

   SALES > 199, BONUS)

  Was this answer useful?  Yes

raj

  • Dec 27th, 2005
 

u can use decode in conditioning coloumns also while we cann't use iff but u can use case. but by using decode retrieveing data is quick  

  Was this answer useful?  Yes

Vaishali

  • Jun 25th, 2007
 

Decode can be used in select statement whereas IIF cannot be used.

  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