我有一张订单表 表结构如下 
订单号(ID)  商品类别  下单时间  订单金额  
00000001      a          2009-09-20    50 
00000002      b          2009-09-20    33 
00000003      a          2009-09-20    90 
........      ..        ..........    .. 
........      ..        ..........    .. 
00000016      a          2009-09-23    120 请问各位如何可以得到每一天a类商品的销售金额总和 
谢谢
注意需要把每天所有的订单金额相加得到总和
比如如果2009-09-20有3笔a商品订单 价格分别为 30 30 90 
得到的结果应该为150 

解决方案 »

  1.   

    select 下单时间, sum(订单金额) from 订单表 where 商品类别=a and 下单时间=to_date('2009/09/20','yyyy/mm/dd') group by 下单时间
      

  2.   

    select sum(money) from test
    where type=a
    group by time
      

  3.   

    时间是date类型的吗?
    select 商品类别,trunc(下单时间,'dd'),sum(订单金额) 
    from table1 
    group by 商品类别,trunc(下单时间,'dd') 
    where 商品类别='a'
      

  4.   

    具体需求应该是这样的 需要得到一定时间段内 比如一个星期内  a类商品每天的单量以及金额总和 时间是date类型的
      

  5.   

    select decode(grouping(id),1,'合计',id) id,sum(money) money
    from 订单表 where type='a' and t.time>=to_date('2009/09/20','yyyy/mm/dd') and t.
    time<=to_date('2009/09/27','yyyy/mm/dd') group by rollup(id,time,type)
      

  6.   

    select 商品类别,trunc(下单时间,'dd'),sum(订单金额) 
    from table1 
    group by 商品类别,trunc(下单时间,'dd') 
    where 商品类别='a'
    这是按天统计
    按月将'dd'改成'mm'
    星期改成'iw'
    年改成'yy'
      

  7.   

    select decode(grouping(id),1,'合计',id) id,sum(money) money 
    from 订单表 where type='a' and t.time>=to_date('2009/09/20','yyyy/mm/dd') and t. 
    time <=to_date('2009/09/27','yyyy/mm/dd') group by rollup(id,time,type)
    union all
    select decode(grouping(time),1,'合计',time) time,sum(money) money 
    from 订单表 where type='a' and t.time>=to_date('2009/09/20','yyyy/mm/dd') and t. 
    time <=to_date('2009/09/27','yyyy/mm/dd') group by rollup(time,type)