繁体   English   中英

在 db2 sql 中编写查询时出现错误。 我需要有 3 个条件的 CASE

[英]I am getting error while writing query in db2 sql. I need to have a CASE with 3 conditions

这是我的查询:

select CASE IF(DATE(Stud40.Start_DT) > '0001-01-01') 
  THEN Stud40.Start_DT
    ELSE IF(Stud40.Start_DT IS NULL) 
        THEN Stud50.Start_DT 
           ELSE Stud.Start_DT END AS "Stud_joining_DT",

我的错误是:

SQL Error [42601]: ILLEGAL SYMBOL ">". SOME SYMBOLS THAT MIGHT BE LEGAL ARE:. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.9.78

case

select (case when date(Stud40.Start_DT) > '0001-01-01'
             then Stud40.Start_DT
             when Stud40.Start_DT IS NULL
             then Stud50.Start_DT 
             else Stud.Start_DT 
        end) as " Stud_joining_DT ",

为什么要在列别名中放置空格?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM