over():指定数据窗口大小current now:当前行preceding:前n行following: 后n行lag(col, n): 往前第n行数据lead(col,n):往后第n行数据
分析函数要和窗口函数配合使用 常用排序函数
rank: 排序相同时会重复,总数不会改变dense rank():排序相同时会重复,总数会减少row_number():会根据顺序计算
select name, subject, score,rank() over(partition by subject order by score desc) rp, dense_rank() over(partition by subject order by score desc) drp, row_number() over(partition by subject order by score desc) rmp from score;