生成按某个字段排序后的序列号
2008-12-10 09:18
239 查看
Sql Server 2005:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select row_number() (order by col) as id, * from tablename
非Sql Server 2005:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select (select count(*) from tablename b where a.col <= b.col) as ID, a.* from tablename a order by a.col
若表中没有自动增长的列:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select IDENTITY(1,1) as ID, * into tb from tableName
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select * from tb
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select row_number() (order by col) as id, * from tablename
非Sql Server 2005:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select (select count(*) from tablename b where a.col <= b.col) as ID, a.* from tablename a order by a.col
若表中没有自动增长的列:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select IDENTITY(1,1) as ID, * into tb from tableName
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
select * from tb
相关文章推荐
- Oracle sql以某个汉字的字段的汉语拼音作为排序,java代码排序不能按要求显示序列号
- 生成多字段排序分页的SQL的通用类
- 排序 SELECT INTO 生成的表 默认的一个排序序号字段是,自增长标识列
- 按某一字段排序生成名次
- SQL Sever生成修改所有字段排序规则
- 通用的泛型Icomparer生成类,对类进行排序,最大支持4个字段同时比较
- 生成多字段排序分页的SQL的通用类
- 生成按某个字段排序后的序号
- 通用的泛型Icomparer生成类,对类进行排序,最大支持4个字段同时比较
- SQL语句order by两个字段同时排序。
- java List多字段排序
- java中List按照指定字段排序工具类
- PHP 二维数组根据某个字段排序
- DEDECMS打造自定义字段排序(GBK版)(转载)
- PHP生成唯一序列号,多台服务器上不重复
- List使用linq的OrderBy方法排序,并按照两个字段排序的写法
- 二维数组字段排序
- PHP+Mysql实现多关键字与多字段生成SQL语句的函数
- List<Map<String,Object>>集合根据map里面的一个字段排序
- Mysql中对字符串类型的字段进行数字值排序