我在下面的查询中收到错误。有人可以建议。
select Defects_1.id,
case when Defects_1.status Not Like '4-Closed%' then (CURRENTDATE() - Defects_1.creation_time) As Defect_Age end
case when Defects_1.status Like '4-Closed%' then Defects_1.user_11as Defect_Age end
from Defects_1
Order By Defects_1.id
错误:
不匹配的输入'不'期望在第2行的PARSER阶段, 第27栏供查询
答案 0 :(得分:0)
我假设你有一些像 Defects_1.closing_time 这样的专栏,这就是你想要的 -
select Defects_1.id
, case
when Defects_1.status Not Like '4-Closed%'
then CURRENTDATE()
else Defects_1.closing_time
end
- Defects_1.creation_time As Defect_Age
,case
from Defects_1
Order By Defects_1.id
答案 1 :(得分:0)
我认为你想要一个case
声明:
select Defects_1.id,
(case when Defects_1.status Not Like '4-Closed%'
then (CURRENTDATE() - Defects_1.creation_time)
when Defects_1.status Like '4-Closed%'
then Defects_1.user_11
end) as Defect_Age
from Defects_1
Order By Defects_1.id