A表中有一个时间型的字段,要求查出本月的数据和上月的数据,请问有没有简例的方法

解决方案 »

  1.   

    初步想法用LEAD分析函数,最好来点数据和相应的结果。
      

  2.   

    --如:tab(id number,u_date date,score number(8,2))select id,sum(score) from tab where to_char(u_date,'yyyy-mm')='2008-10' group by id;
      

  3.   

    select * from a where rq>=(to_date(trunc(sysdate,'MM'),'yyyy-mm-dd')- interval '1' month) 
      

  4.   

    select * from a where rq>=(trunc(sysdate,'MM')- interval '1' month)