一、
select count(*),unit,flow_name from (
select count(*) as c,t.unit,f.flow_name from (select * from todo union select * from done) t,gdtel_user u1,gdtel_group g1,gdtel_group g2,flow_config f where
t.user_id=u1.userid and u1.groupid=g1.groupid and g1.parentid=g2.groupid and t.flow_name=f.flow_id and start_time>=to_date('2010-03-01 00:00:00','YYYY-MM-DD hh24:mi:ss') and g2.group_name not like '%分公司%' and unit not like '%分公司%' and
start_time<=to_date('2010-03-31 00:00:00','YYYY-MM-DD hh24:mi:ss') group by f.flow_name,t.unit,t.main_doc_id) group by unit,flow_name
二、
select count(*) as c,f.flow_name,g1.group_name,g2.group_name from (select * from todo union select * from done) t,gdtel_user u1,gdtel_group g1,gdtel_group
g2,flow_config f where t.user_id=u1.userid and u1.groupid=g1.groupid and g1.parentid=g2.groupid and t.flow_name=f.flow_id and
start_time>=to_date('2010-03-01 00:00:00','YYYY-MM-DD hh24:mi:ss') and g2.group_name not like '%分公司%' and unit not like '%分公司%' and
start_time<=to_date('2010-03-31 00:00:00','YYYY-MM-DD hh24:mi:ss') group by f.flow_name,g1.group_name,g2.group_name
就是上面两段,高手帮帮啊!万分感谢!