groupId scduleDate
1 '2016-10-5 10:30:00'
2 '2016-10-4 10:30:00'
3 '2016-10-19 10:30:00'
4 '2016-10-19 10:30:00' 这是我的表,我必须根据条件动态地获取一个列
我正在尝试使用这个,但我无法获得价值。
select groupId,scduleDate
,
case scheduledDate when >now then "1"
else '0'
end
as Real_Title
from EventList_View我的预期输出如下:
groupId scduleDate status
1 '2016-10-5 10:30:00' 0
2 '2016-10-4 10:30:00' 0
3 '2016-10-19 10:30:00' 1
4 '2016-10-19 10:30:00' 1我想-应用条件,基于今天的日期和以前的日期,因此,我想添加状态,如果前一个日期,从今天的日期,它应该0其他1,但当我试图执行我的查询,没有任何数据来,请告诉我哪里做错了。
发布于 2016-10-12 09:16:00
https://dev.mysql.com/doc/refman/5.7/en/case.html表达式中有语法错误。
查询
select groupId,scduleDate,
case when scduleDate > now() then 1 else 0 end as Real_Title
from EventList_View;https://stackoverflow.com/questions/39994781
复制相似问题