select to_char(sysdate-90,'yyyy-mm-dd') from dual; 和现在差90天的日期的写法!所以要取值: select id,date from transaction where to_date(to_char(sysdate-90,'yyyy-mm-dd'),'yyyy-mm-dd')-to_date(date,'yyyy-mm-dd')>90
select id,date from transaction where SYSDATE - DATE >=90;
select * from transaction where SYSDATE - DATE >=90;
sysdate-date这样是精确到毫秒的 如果只需要到天就套个trunc
按自上面的回复 select * from transaction where date <=sysdate-90; --优select * from transaction where SYSDATE - DATE >=90; --差查询的字段放在关系符的左边,最好没有运算。以方便数据库使用索引
和现在差90天的日期的写法!所以要取值:
select id,date from transaction where to_date(to_char(sysdate-90,'yyyy-mm-dd'),'yyyy-mm-dd')-to_date(date,'yyyy-mm-dd')>90
如果只需要到天就套个trunc
select * from transaction where date <=sysdate-90; --优select * from transaction where SYSDATE - DATE >=90; --差查询的字段放在关系符的左边,最好没有运算。以方便数据库使用索引