Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to rewrite an nested IFF statement to oracle case when statement

How to rewrite the following nested IFF statement to oracle Case when statement .

IIF(IN_RNK = 1,
IIF(IN_SUM > 2,IIF(IN_MTR_COVERAGE_NUMBER_A = 'A','ORIGINAL BASE','ORIGINAL RIDER'),IN_MTR_COVERAGE_NUMBER_A),
IN_MTR_COVERAGE_NUMBER_A)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Like this:

CASE
WHEN IN_RNK = 1
THEN CASE
     WHEN IN_SUM > 2
     THEN CASE 
          WHEN IN_MTR_COVERAGE_NUMBER_A = 'A'
          THEN 'ORIGINAL BASE'
          ELSE 'ORIGINAL RIDER'
          END
     ELSE IN_MTR_COVERAGE_NUMBER_A
     END
ELSE IN_MTR_COVERAGE_NUMBER_A
END

Which can be simplified to:

CASE
WHEN in_rnk = 1 AND in_sum > 2 AND in_mtr_coverage_number_a = 'A'
THEN 'ORIGINAL BASE'
WHEN in_rnk = 1 AND in_sum > 2
THEN 'ORIGINAL RIDER'
ELSE in_mtr_coverage_number_a
END
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading