如何让所请读取的数据自动产生编号.
2005-10-06 12:59
411 查看
如何让所请读取的数据自动产生编号…
方法-:
Select Serial_numbr=( select count(1)+1 from Table_Name
Where number_code<=t.number_code),*
From Table_Name t
(其中的count(1)+1 也可以换成 isnull(sum(1),0)+1
因为sum(1) 会在第一人序号产生为 NULL ,所以用isnull 函数换成 0 )
方法二:(利用#table_temp 临时表来实现)
Select identity(int,1,1) as Serial_Number,* into #table_temp
From Table_Name
Select * from #table_temp
Drop table #table_temp
方法-:
Select Serial_numbr=( select count(1)+1 from Table_Name
Where number_code<=t.number_code),*
From Table_Name t
(其中的count(1)+1 也可以换成 isnull(sum(1),0)+1
因为sum(1) 会在第一人序号产生为 NULL ,所以用isnull 函数换成 0 )
方法二:(利用#table_temp 临时表来实现)
Select identity(int,1,1) as Serial_Number,* into #table_temp
From Table_Name
Select * from #table_temp
Drop table #table_temp
相关文章推荐
- 如何让所请读取的数据自动产生编号.
- mysql insert语句后如何获取insert数据的主键值自动编号
- mysql如何把查询到的数据加上一个自动编号字段
- 如何让SELECT 查询结果额外增加自动递增序号 如果数据表本身并不内含自动递增编号的字段时,要怎么做才能够让SELECT查询结果额外增加自动递增序号呢?下列五种方法供您参考: USE test;
- mysql删除数据记录后如何使自动编号从1开始
- oracle数据库表中,插入数据的时候如何产生一个 字母+数字 编号?
- insert语句后如何获取insert数据的主键值自动编号
- mysql insert语句后如何获取insert数据的主键值自动编号
- Word 2010如何取消回车后自动产生的编号
- MapReduce 中如何处理HBase中的数据?如何读取HBase数据给Map?如何将结果存储到HBase中?
- C#2.0中,SerialPort如何读取串口数据并显示在TextBox上
- 如何写批处理文件自动将数据导入oracle数据库
- Web开发——如何使JDBC插入数据的时候返回自动增长的主键值
- 如何在网页读取用户IP,操作系统版本等数据demo
- 讲解Linux系统下如何自动备份MySQL数据的基本教程
- 通过广播监听WiFi连接状态,自动读取数据WifiManager /NetworkInfo
- ACCESS自动编号从1开始-如何让access自动编号重新从1开始排序的方法
- 在IOS中如何读取系统产生的plist文件和自定义的plist文件
- python如何获取javascript动态产生的数据
- 如何从文本文件读取数据到二维数组,如何在函数处理后返回二维数组的示例