1.ROW_NUMBER ( )
OVER ( [ PARTITION BY value_expression , ... [ n ] ] order_by_clause )
PARTITION BY是可选参数,如果不使用这个参数,则表示记录行号。如果是用这个参数则是表示小组里面记录的行号。
使用例子:删除重复的记录。
DELETE FROM dbo.[User] WHERE ID in (SELECT ID FROM (SELECT ID,ROW_NUMBER() OVER (partition by name order by id) rowN from dbo.[User])B where B.rowN>1)