我有一个包含 3 列的表,其中包括一个名为的时间戳startson
:
事件(eventid编号、名称varchar2、startson时间戳)
我有一个变量,它是一个偏移量,表示startson
我的 where 子句中的边界应该是什么。
例如:
if my_var = 0 (select events that started in the last 10 days)
if my_var = 1 (select events that started 20 days ago up until 10 days ago)
if my_var = 2 (select events that started 30 days ago up until 20 days ago)
if my_var = 3 (select events that started 40 days ago up until 30 days ago)
.. and so on
这是我尝试过的:
select *
from events
where startson >= (sysdate-(10*my_var))
and startson <= (sysdate-(10*my_var+10))
order by startson asc
即使我知道过去 10 天内有数百行开始,这也不会返回任何行。