sql字段排序 rank over

SELECT
    s.stat_dt
   ,s.day_sale_amt_val--金额
   ,s.day_sale_num_val---数量
   ,s.sale_num_sort
   ,s.sale_amt_sort
   ,RANK() OVER (PARTITION BY s.stat_dt ORDER BY s.day_sale_amt_val DESC)
      ,RANK() OVER (PARTITION BY s.stat_dt ORDER BY s.day_sale_num_val DESC)
FROM temp1_T88_EPS_TXN_MER_DAY_STAT S

按照金额和数量排序值放在 sort字段里

 

 

 

 

 


SQL语句为:SELECT MONTH_ID AS 月份,AREA_NAME AS 地市名称,AGE AS 收入,FIRST AS 支出,
ROW_NUMBER()OVER(PARTITION BY MONTH_ID ORDER BY AGE DESC) 收入排名,
ROW_NUMBER()OVER(PARTITION BY MONTH_ID ORDER BY FIRST DESC)支出排名 FROM TABLE_NAME

 

你可能感兴趣的:(sql,职场,rank,over,休闲,派讯)