select c.dsc 订货方式,count(distinct a.orderid) 订单总数,d.orid 成功订单总数,h.gnum 成功订货款 ,decode(count(distinct a.orderid),0,0,to_char(d.orid/count(distinct a.orderid),'0D999')) 订单成功率 from orderhist a,names c, orderdet y, (select f.dsc fdsc,COUNT(distinct e.orderid) orid from orderhist e,names f,orderdet x where e.orderid=x.orderid and e.status = '5' and e.mailtype = f.id and f.TID = 'BUYTYPE' and trunc(e.crdt) between to_date('^1','yyyy-mm-dd') and to_date('^2','YYYY-MM-DD') and x.soldwith in ('1','2','3') --and e.ordertype in (select id from names where tid = 'ORDERTYPE' and dsc = '^3') group by f.dsc) d, (select f.dsc hdsc, sum(g.uprice*g.upnum + g.sprice * g.spnum) gnum from orderhist e,names f,orderdet g