Annie Jeba
Annie Jeba

Reputation: 379

Case Statement on Multiple conditions in Oracle

CASE test
WHEN  NULL and  SUBSTR(('99999999' - Tst_Date),1,4) > 2009 THEN 'Medi'                     
WHEN   NULL and SUBSTR(('99999999' - Tst_Date),1,4) < 2009 THEN 'hills'
ELSE test
END AS "Phy"

Am i missing something in the above case statement? I keep on getting 00905. 00000 - "missing keyword" error?

Upvotes: 13

Views: 108392

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521339

Your syntax is a little bit off. Use this:

CASE WHEN test IS NULL AND SUBSTR(('99999999' - Tst_Date),1,4) > 2009 THEN 'Medi'
     WHEN test IS NULL AND SUBSTR(('99999999' - Tst_Date),1,4) < 2009 THEN 'hills'
     ELSE test
END AS "Phy"

Upvotes: 26

Related Questions