把最外围的 select * from  ( ..........)  where nub <> 0  执行效率基本没有问题
一旦加上  查数据 那是相当的 相当的慢了!~~~
select * from 
       (select pid,
               pname,
               is_proxy,
               fname,
               nvl(isum, 0) isum,
               nvl(qsum, 0) qsum,
               nvl(outsale, 0) outsale,
               nvl(insale, 0) insale,
               nvl(isum, 0) + nvl(qsum, 0) + nvl(outsale, 0) +
               nvl(insale, 0) as nub
          from (
                
                select pid,
                        pname,
                        is_proxy,
                        fname,
                        (select sum(quantity) qtity
                           from proxy_saleout ca
                           join proxy_saleout_b imb on ca.billid = imb.billid
                          where ca.channel_id = pid
                            and ca.ts >= '2013-08-28'
                            and ca.ts <= '2013-09-28'
                          group by ca.channel_id) isum,
                        
                        (select sum(quantity)
                           from chan_purchase ca
                           join chan_purchase_b pub on pub.billid = ca.billid
                          where ca.channel_id = pid
                            and ca.ts >= '2013-08-28'
                            and ca.ts <= '2013-09-28'
                          group by ca.channel_id) qsum,
                        (select sum(outsale)
                           from chan_currentsales ca
                          where ca.proxy_id = pid
                            and ca.billdate >= '2013-08-28'
                            and ca.billdate <= '2013-09-28'
                          group by ca.proxy_id)
                        
                        outsale,
                        (select sum(insale)
                           from chan_currentsales ca
                          where ca.proxy_id = pid
                            and ca.billdate >= '2013-08-28'
                            and ca.billdate <= '2013-09-28'
                          group by ca.proxy_id)
                        
                        insale
                  from (select pro.proxy_id pid,
                                proxy_name pname,
                                case
                                
                                  when is_proxy = 0 then
                                   '代销渠道'
                                  when is_proxy = 2 then
                                   '四五星门店'
                                  when is_proxy = 4 then
                                   '合作厅'
                                  when is_proxy = 5 then
                                   '电子渠道'
                                
                                end is_proxy,
                                f.filiale_name fname
                           from bd_proxy pro
                           join bd_filiale f on pro.filiale_id = f.filiale_id
                          where is_proxy <> 1))
                          
                          ) where nub <> 0