【SQL】ROW_NUMBER() OVER(partition by 分组列 order by 排序列)

发布时间 2023-08-18 10:15:42作者: 小小刺猬

select row_number() over(partition by A order by B ) as rowIndex from table

 

 

A :为分组字段
B:为分组后的排序字段。
table 表的结构 多为:  多人 多条的相关数据。(比如:订单信息)