我尝试使用以下语句来检查订单是否延迟,但会导致语法错误。我怎么写呢?
select (enddate > targetdate ) as late from orders
答案 0 :(得分:4)
您似乎正在搜索与case
表达式类似的内容:
select
case
when enddate > targetdate then 1
else 0
end as late
from orders
答案 1 :(得分:1)
我想你需要case
select
case
when enddate > targetdate then 'enddate is greater'
else 'targetdate is greater'
end as late
from orders