SELECT ROW_NUMBER() OVER (PARTITION BY partition_column ORDER BY order_column)
FROM tablename
PARTITION BY 可选,它将结果集按照分区列分为多个分区,函数分别应用于每个分区,并为每个分区重新启动计算。
如下列查询结果
Rownumber Category ProductName
1 Book My Life2 Book Harry Poter
3 Book Beginning C++
1 Pencil 2B
2 Pencil HB