Home  >  Article  >  Database  >  【ROW_NUMBER 函数(Transact-SQL)】

【ROW_NUMBER 函数(Transact-SQL)】

WBOY
WBOYOriginal
2016-06-07 17:37:421135browse

【ROW_NUMBER 函数(Transact-SQL)】返回结果集分区内行的序列号,每个分区的第一行从 1 开始。 注释: ROW_NUMBER() OVER (PARTITION BY COL1 ORDER BY COL2) --(其中,COL1,COL2可以为多列) select xt.id,xt.item,xt.attribute1,xt.attribute2,ROW_NUMBER(

【ROW_NUMBER 函数(Transact-SQL)】返回结果集分区内行的序列号,每个分区的第一行从 1 开始。

注释: ROW_NUMBER() OVER (PARTITION BY COL1 ORDER BY COL2) --(其中,COL1,,COL2可以为多列)

select xt.id, xt.item, xt.attribute1, xt.attribute2, ROW_NUMBER() OVER(PARTITION BY xt.id,xt.item order by xt.id,xt.item) test from xxuts_test xt

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn