当前位置: 代码迷 >> 综合 >> orcle ?row_number() 用法 序号的生成
  详细解决方案

orcle ?row_number() 用法 序号的生成

热度:71   发布时间:2023-11-18 08:06:32.0

 语法

SELECTROW_NUMBER() OVER(ORDER BY  sta.ID_) feenum,aa,bbFROMsta
SELECTrow_number() over (order by J.ID_) feenum,desc_,month_cost,month_tax,month_fee,year_cost,year_tax,year_fee
FROM(SELECTA .desc_,A .ID_,NVL (b.month_cost, 0) month_cost,NVL (b.month_tax, 0) month_tax,NVL (b.month_fee, 0) month_fee,NVL (b.year_cost, 0) year_cost,NVL (b.year_tax, 0) year_tax,NVL (b.year_fee, 0) year_feeFROM(SELECT*FROMbdf2_dept DWHERED .parent_id_ = '00'AND D .level_ = '1') ALEFT JOIN (SELECT*FROMsaf_t_fee fWHEREf.del_flag = '0') b ON A .id_ = b.dept_idAND b.report_date >= TO_DATE ('2018-12-01', 'yyyy-MM-dd')AND b.report_date <= TO_DATE ('2018-12-31', 'yyyy-MM-dd')UNION ALLSELECT'合计' desc_,'a' ID_,SUM (month_cost) month_cost,SUM (month_tax) month_tax,SUM (month_fee) month_fee,SUM (year_cost) year_cost,SUM (year_tax) year_tax,SUM (year_fee) year_feeFROM(SELECTA .desc_,NVL (b.month_cost, 0) month_cost,NVL (b.month_tax, 0) month_tax,NVL (b.month_fee, 0) month_fee,NVL (b.year_cost, 0) year_cost,NVL (b.year_tax, 0) year_tax,NVL (b.year_fee, 0) year_feeFROM(SELECT*FROMbdf2_dept DWHERED .parent_id_ = '00'AND D .level_ = '1') ALEFT JOIN (SELECT*FROMsaf_t_fee fWHEREf.del_flag = '0') b ON A .id_ = b.dept_idAND b.report_date >= TO_DATE ('2018-12-01', 'yyyy-MM-dd')AND b.report_date <= TO_DATE ('2018-12-31', 'yyyy-MM-dd'))) J
ORDER BYJ.ID_

 

  相关解决方案