http://blog.163.com/neso520@126/blog/static/16275753620104272349605/
select Identity(int,1,1) as rowIndex,Title,hits into #tmp
from(Select TOP 100 Percent * from _Table order by hits desc) b
select * from #tmp
drop table #tmp
----------------------------------------
解释:#tmp是个虚拟表,不用改这个表的名字。
Select TOP 100 Percent * from _Table order by hits desc
上面这一句是你要添加行号的select语句。
Title,hits必须包含在上面这条select语句的结果中。
“b”一定不可以去掉。
本文详细介绍了如何利用SQL语句创建虚拟表,并通过虚拟表实现对数据集的排序及添加行号的操作。重点阐述了`TOP 100 Percent * from _Table orderby hitsdesc`查询语句的功能与应用,同时强调了虚拟表`#tmp`的重要性以及在实际数据处理中的灵活运用。
7099

被折叠的 条评论
为什么被折叠?



