1、统计每月的成交量,按照逆序排序(2013年以来的每月销量,oracle实现)
select to_char(t.payment_time,'yyyy-MM'),count(t.id) as 笔数,sum(t.payment_amount) as 月总金额 from business_journal t where t.payment_type='11' and t.err_code='00' and
to_date(to_char(t.payment_time,'yyyy-MM-dd'),'yyyy-MM-dd')>to_date('2012-12-31','yyyy-MM-dd') group by to_char(t.payment_time,'yyyy-MM') having count(t.id)>0
order by to_char(t.payment_time,'yyyy-MM') desc ;
select to_char(t.payment_time,'yyyy-MM'),count(t.id) as 笔数,sum(t.payment_amount) as 月总金额 from business_journal t where t.payment_type='11' and t.err_code='00' and
to_date(to_char(t.payment_time,'yyyy-MM-dd'),'yyyy-MM-dd')>to_date('2012-12-31','yyyy-MM-dd') group by to_char(t.payment_time,'yyyy-MM') having count(t.id)>0
order by to_char(t.payment_time,'yyyy-MM') desc ;
本文展示了如何利用Oracle SQL语句,通过日期筛选和分组功能,统计2013年1月以来每个月的交易笔数和总金额,提供了一种高效的数据分析方法。
3095

被折叠的 条评论
为什么被折叠?



