ORACLE 时间问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 18:51:21
我想按照季度统计我的一个表数据

select flowlib.name,
sum(case when wfass.createddate between to_date('1-1','MM/DD') and to_date('3-31','MM/DD')+1 then 1 else 0 end) as 第一季度,

sum(case when wfass.createddate between to_date('4-1','MM/DD') and to_date('6-30','MM/DD')+1 then 1 else 0 end) as 第二季度,

sum(case when wfass.createddate between to_date('7-1','MM/DD') and to_date('9-30','MM/DD')+1 then 1 else 0 end) as 第三季度,

sum(case when wfass.createddate between to_date('10-1','MM/DD') and to_date('12-31','MM/DD')+1 then 1 else 0 end) as 第四季度

from wfassignment wfass,tuser,wfprocess wfinst,flowlib
where wfass.assignee=tuser.userid
and wfass.processid=wfinst.id
and wfinst.defid=flowlib.processid
and wfass.createddate > to_date('2008-1-1','YYYY/MM/DD') and wfass.createddate<to_d

(1)('2009-1-1','YYYY/MM/DD') 这么写也没问题,至少在PL/SQL中可以,
(2)我觉得是否是你的报表工具在分析SQL语句时,不允许这样写——to_date('10-1','MM/DD')

看看这个,也许和您的问题类似:
http://www.itpub.net/viewthread.php?tid=983672

倒数第二行这样写
('2009-01-01','YYYY/MM/DD')