多语言展示
当前在线:429今日阅读:126今日分享:42

sqlite case when 语句注意

sqlite case when 语句
方法/步骤

sqlite3也是支持case when语句的,但是我写的select 住院号,     case when strftime('%w',出院日期)in (3,4,5,6)And julianday(出科日期)- julianday(出院日期) between 3 and 5 then  julianday(出科日期)- julianday(出院日期)-2else julianday(出科日期)- julianday(出院日期)      end as 天数    from 出科明细一直不起作用,不管怎么改,结果都是julianday(出科日期)- julianday(出院日期)在网上也找不到原因,后来测试出来when语句的值要加单引号才起作用,上面语句改为以下形式就可以了when strftime('%w',出院日期)in ('3','4','5','6')And julianday(出科日期)- julianday(出院日期) between 3 and 5 then  julianday(出科日期)- julianday(出院日期)-2我也测试过用“>,<,='等运算符时也要加单引号,但between不能加,加上反而出错。

推荐信息