Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case Statement on Multiple conditions in Oracle

Tags:

sql

case

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?

like image 918
Annie Jeba Avatar asked Oct 25 '16 02:10

Annie Jeba


1 Answers

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"
like image 115
Tim Biegeleisen Avatar answered Sep 29 '22 16:09

Tim Biegeleisen