--月统计
   Select SUBSTR(t.BalanceDate,1,6) as Mon,  t.RechargeType ,  
    SUM(t.SumNum) as SumNum ,   
    SUM(t.SumFee) as SumFee    
    From  Recharge    t 
    Where  
    to_char(to_date(t.BalanceDate,'yyyy-mm-dd'),'yyyymm') BETWEEN to_char(to_date('2016-07-01','yyyy-mm-dd'),'yyyymm') 
    AND to_char(to_date('2016-07-01','yyyy-mm-dd'),'yyyymm') and  t.rechargetype='1'
    Group  by  SUBSTR(t.BalanceDate,1,6) , t.RechargeType 
    Order by SUBSTR(t.BalanceDate,1,6)  DESC
--年统计 Select SUBSTR(t.BalanceDate,1,4) as Year, t.RechargeType , SUM(t.SumNum) as SumNum , SUM(t.SumFee) as SumFee From Recharge t Where to_char(to_date(t.BalanceDate,'yyyy-mm-dd'),'yyyy') BETWEEN to_char(to_date('2016-07-01','yyyy-mm-dd'),'yyyy') AND to_char(to_date('2016-07-01','yyyy-mm-dd'),'yyyymm') and t.rechargetype='1' Group by SUBSTR(t.BalanceDate,1,4) , t.RechargeType Order by SUBSTR(t.BalanceDate,1,4) DESC

根据年月统计分组 请注意group by 和order by 排序字段 要和查询条件的取值一样。点点滴滴随记一笔。

相关文章:

  • 2021-10-08
  • 2021-12-30
  • 2021-11-15
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案