码迷,mamicode.com
首页 > 数据库 > 详细

SQL查询结果增加序号列

时间:2015-01-04 16:52:37      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

--sql 2000
select 序号 = (select count(1) from tb where 学号 < t.学号) + 1,学号 ,姓名 from tb t

--sql 2005
select 序号 = row_number() over(order by 学号),学号 ,姓名 from tb

--oracle
select row_number() over(order by 学号) 序号,学号 ,姓名 from tb

 

SQL查询结果增加序号列

标签:

原文地址:http://www.cnblogs.com/shenyixin/p/4201316.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!