sql 统计类语句

  • Post author:
  • Post category:其他
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 ;

版权声明:本文为stevenbill原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。