例如:
select *
from Table
where startdate >= sysdate-10 and name='abc'
order by startdate.需要最以前的记录,这是在过去的10天。
例如:SYSDATE=26-Jul-2015,在2015年7月16日之前只需要一个最新记录。
发布于 2015-07-27 10:31:32
我认为您只需使用查询并选择第一个行号即可。第一种方法适用于所有版本的Oracle:
select t.*
from (select t.*
from Table t
where startdate >= sysdate-10 and name='abc'
order by startdate
) t
where rownum = 1;在Oracle 12+中,您可以简单地执行以下操作:
select t.*
from Table t
where startdate >= sysdate-10 and name='abc'
order by startdate
fetch first 1 row only;https://stackoverflow.com/questions/31644111
复制相似问题