ITeye博客

sql 统计类语句

stevenjohn · 2014-03-17 16:59 · DataBase · 数据库 · Markdown

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 ;

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。