我的表中有 4 个日期时间列way_point
。这四列是
scheduled_a, checkin_time, no_later_than, no_earlier_than
现在我想看看在价值观scheduled_a
,checkin_time
降幅之间no_later_than
和no_earlier_than
列。
这是我编写的代码,但出现此错误:
在预期条件的上下文中指定的非布尔类型的表达式,靠近“and”。
代码:
select
customer_id, position
from
way_points
where
position = 2
and [scheduled_a] and [checkin_time] between [no_later_than] and [no_earlier_Than]
Position
这里是另一列,我必须将其用作 where 的条件。但主要是我坚持比较日期时间列。
知道我可能哪里错了吗?谢谢你。
你快到了。您需要将其拆分为两个不同的条件。不能说 no_later_than 或 no_earlier_than 是否更大。在between
第一个参数之后需要是较小的。例如 if no_later_than = '2016-02-22'
and no_earlier_than = '2016-02-23'
thenno_later_than
是较小的参数。
select customer_id,position
from way_points where position=2
and [scheduled_a] between no_later_than and [no_earlier_than]
and [checkin_time] between no_later_than and [no_earlier_than]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句