【发布时间】:2019-11-26 01:57:42
【问题描述】:
我正在触发一个 SQL 查询来过滤 sysdate 和 sysdate+7 之间的记录,但我也得到了超出范围的记录。我的 SQL 出了什么问题
cursor.execute("""
select
'Shipment' as object_type
, trunc(sc.effective_timestamp) reference_date
, sc.location_name location
from
master.cons_search c
inner orbit.status_cons sc ON (c.tms_cons_id=sc.cons_id)
where
1=1
AND c.global_company IN ('SWEET234')
AND sc.type = '1201'
and (trunc(c.ets) >= trunc(sysdate) and trunc(c.ets) <= (trunc(sysdate) + 7))
""")
data=cursor.fetchall()
我什至尝试了between function
and trunc(c.ets) between trunc(sysdate) and (trunc(sysdate) + 7)
但他们都给出了超出范围的结果。这里有什么问题?
【问题讨论】: