SQL Server排序函数row_number和rank的区别

SQL Server排序函数row_number和rank的区别

直接看测试结果

declare @table table(name varchar(100),amount int, memo varchar(10))
insert into @table(name,amount,memo)
values('apple',8,'123')
,('apple',10,'123')
,('apple',12,'235')
,('orange',11,'123')
,('orange',14,'123')
,('pear',9,'123')

row_number

select row_number()over(order by name) as rn,* from @table

SQL Server排序函数row_number和rank的区别

rank

select rank()over(order by name) as rn,* from @table

SQL Server排序函数row_number和rank的区别

上一篇:HBase 系列(三)HBase Shell


下一篇:nagios 在nrpe中自定义脚本