日期:2014-05-20  浏览次数:21110 次

报表统计--sql语句
create   or   replace   view   viw_miles_correct_report   as
select
f.operation_description   operTypeDesc,
RequestTimes,
oneCheckTimes,
round(oneCheckTimes/RequestTimes,4)   scale1,
upTimes,
round(upTimes/RequestTimes,4)   scale2,
twoCheckTimes,
round(twoCheckTimes/RequestTimes,4)   scale3,
oneInputTimes,
round(oneInputTimes/RequestTimes,4)   scale4,
twoInputTimes,
round(twoInputTimes/RequestTimes,4)   scale5
from
(
select
A.OPERATION_TYPE_CODE   operTypeCode,
count(A.RECORD_ID)   RequestTimes,        
(select   count(b.RECORD_ID)   from   tbl_operation_manage   b
    where   a.operation_type_code=b.operation_type_code
    and   b.operation_status_code= 'A '
    and   b.operate_date  
    between   to_date( '2006/01/01 ', 'YYYY/mm/dd ')   and   to_date( '2008/01/03 ', 'YYYY/mm/dd '))     oneCheckTimes,
(select   count(c.RECORD_ID)   from   tbl_operation_manage   c
    where   a.operation_type_code=c.operation_type_code
    and   c.operation_status_code= 'U '
    and   c.operate_date  
    between   to_date( '2006/01/01 ', 'YYYY/mm/dd ')   and   to_date( '2008/01/03 ', 'YYYY/mm/dd '))     upTimes,
(select   count(d.RECORD_ID)   from   tbl_operation_manage   d
    where   a.operation_type_code=d.operation_type_code
    and   d.operation_status_code= 'B '
    and   d.operate_date  
    between   to_date( '2006/01/01 ', 'YYYY/mm/dd ')   and   to_date( '2008/01/03 ', 'YYYY/mm/dd '))     twoCheckTimes,
(select   count(e.RECORD_ID)   from   tbl_operation_manage   e
    where   a.operation_type_code=e.operation_type_code
    and   e.operation_status_code= 'Y '
    and   e.operate_date  
    between   to_date( '2006/01/01 ', 'YYYY/mm/dd ')   and   to_date( '2008/01/03 ', 'YYYY/mm/dd '))     oneInputTimes,
(select   count(f.RECORD_ID)   from   tbl_operation_manage   f
    where   a.operation_type_code=f.operation_type_code
    and   f.operation_status_code= 'F '
    and   f.operate_date  
    between   to_date( '2006/01/01 ', 'YYYY/mm/dd ')   and   to_date( '2008/01/03 ', 'YYYY/mm/dd '))     twoInputTimes
from   tbl_operation_manage   A
where   a.operation_type_code= 'MILESCORRECT '
and   a.operate_date   between   to_date( '2006/01/01 ', 'YYYY/mm/dd ')   and   to_date( '2008/01/03 ', 'YYYY/mm/dd ')
group   by   A.OPERATION_TYPE_CODE
)   e,
tbl_operation_type   f
  where   e.operTypeCode=f.operation_code

我现在的视图用到GROUP   BY,不能按时间来查,有什么方法可以解决吗?

------解决方案--------------------
不明白你的问题,你写清楚一点。