熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

Oracle按不同時間分組統計的sql

2022-06-13   來源: Oracle 

  Oracle按不同時間分組統計的sql

  如下表table:

  日期(exportDate)               數量(amount)

                     

                        

                        

                        

                        

                       

                       

                        

                        

                       

  注意為了顯示更直觀如下查詢已皆按相應分組排序

  按年份分組

  select to_char(exportDateyyyysum(amount) from table group by to_char(exportDateyyyy

  年份      數量

  

     

     

     

  按月份分組

  select to_char(exportDateyyyymmsum(amount) from table group by to_char(exportDateyyyymm

  order by to_char(exportDateyyyymm

  月份           數量

  

     

     

     

     

     

     

     

     

     

  按季度分組

  select to_char(exportDateyyyyQsum(amount) from table group by to_char(exportDateyyyyQ

  order by to_char(exportDateyyyyQ

  季度          數量

  

     

     

     

     

     

  按周分組

  select to_char(exportDateyyyyIWsum(amount) from table group by to_char(exportDateyyyyIW

  order by to_char(exportDateyyyyIW

  周             數量

  

     

     

     

     

     

     

     

     

     


From:http://tw.wingwit.com/Article/program/Oracle/201311/17995.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.