select br.branch_name, sum(so.order_price) total
  from sellorders so, storehouse sh, branch br
 where so.store_id = sh.store_id
   and sh.branch_id = br.branch_id
 so.delivery_state = 15
   and so.order_time >= to_date('20150301', 'YYYYMMDD')
   and so.order_time < to_date('20150401', 'YYYYMMDD')
   and so.order_price > 500
 group by br.branch_name;

解决方案 »

  1.   

    sum(so.order_price/10000) total
      

  2.   

    sum(so.order_price)/10000  total
      

  3.   

    SELECT a.branch_id,round(SUM(c.order_price)/10000,2)
    FROM branch a,storehouse b,sellorders c
    WHERE a.branch_id = b.branch_id
    AND b.store_id = c.store_id
    AND c.order_time >= to_date('20150301','yyyymmdd')
    AND c.order_time < to_date('20150401','yyyymmdd')
    AND c.delivery_state=15
    AND c.order_price>500
    GROUP BY a.branch_id--大概就这样
      

  4.   

    1个仓库有两个分公司共用的话、那你怎么确定这个仓库的订单金额是哪个公司的、订单表里应该少一个分公司id字段吧select c.branch_name,concat(round(a.total/10000,2),'万') from
     
     (select store_id,sum(order_price)as total from sellorders
     where delivery_state = 15
       and to_char(order_time,'yyyy-mm')='2015-03'
       group by store_id
       having sum(order_price)>500)a
    inner join storehouse b
            on a.store_id=b.store_id
    left join branch c
           on b.branch_id=c.branch_id