oracle 查询前7天的数据

select nvl(t1.xfc,0) as hj,substr(t.today,6,5) as rq from
(select to_char (sysdate-level + 1,'yyyy-mm-dd') today from dual connect by level <=7 ) t,
(select count(t.运单编号) as xfc,to_char(t.寄件日期,'yyyy-MM-dd') as rq from tab_寄件运单表 t where t.寄件客户编号='KVN01' group by to_char(t.寄件日期,'yyyy-MM-dd')) t1
where t.today=t1.rq(+) order by t.today;

转载于:https://www.cnblogs.com/kongnengjing/p/10476975.html

你可能感兴趣的:(oracle 查询前7天的数据)