日期:2014-05-16  浏览次数:20480 次

查询不同月份不同客户的数据记录

对于数据库不熟悉的需要对下面这个示例进行熟悉

?

select ordermonth 月份,consignment 客户,sum(goodscount) 发货总数量,sum(volume) 发货总体积,sum(weight) 发货总重量
from
(
select SUBSTR(to_char(b.order_time,'YYYY-mm'),1,7) ordermonth,
b.goods_count goodscount,b.volume volume,b.weight weight,
b.consignment_id consignment
from bus_temp_order b
where b.order_time between sysdate-365 and sysdate)
group by ordermonth,consignment
order by consignment