oracle一周内日期查询

select *
  from (SELECT a.*,
               (select count(distinct b.fee_name)
                  from biz_patent_fee_notice b
                 where b.main_id = a.id) notices,
               (select count(distinct b.fee_name)
                  from biz_patent_fee_notice b
                 where b.main_id = a.id
                   and to_date(b.notice_date)-trunc(sysdate) between 1 and 7) dueNotices,
               (select count(distinct b.fee_name)
                  from biz_patent_fee_notice b
                 where b.main_id = a.id
                   and sysdate > b.notice_date) seniorNotices
          FROM biz_patent_fee_main a
         where 1 = 1
         order by ID asc)
 where rownum <= 10


猜你喜欢

转载自vipshow.iteye.com/blog/1711437
今日推荐