sqlite case when 语句注意
1、sqlite3也是支持case when语句的,但是我写的
select 住院号, case when strftime('%w',出院日期)in (3,4,5,6)And julianday(出科日期)- julianday(出院日期) between 3 and 5 then julianday(出科日期)- julianday(出院日期)-2
else 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不能加,加上反而出错。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:83
阅读量:176
阅读量:81
阅读量:80
阅读量:175