sql查询中怎么增加一列数字编号? 例如:select * from users查询出来的结果为:uesr1user2user3如何增加一列数字编号即:1,uesr12,user23,user3 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select ID=identity(int, 1, 1), * into #T from usersselect * from #T select (select count(*) from users where name<=u.name) as id,u.name from users u order by id select id=identity(int,1,1),* into tb from usersselect * from tb drop table tb create table users(col1 nvarchar(20))insert users select 'user1'insert users select 'user2'insert users select 'user3'select ID=identity(int, 1, 1), * into #T from usersselect * from #T--resultID col1 ----------- -------------------- 1 user12 user23 user3 identity(int, 1,1)插入连续的序号 libin_ftsafe(子陌红尘:当libin告别ftsafe)的还不错,数据量大的话效率是个问题 那你用ORACLE好了,SQL2K只能这么做 还是marco08(天道酬勤) 的办法稳一点,如果你的user字段有重复值的话,子陌的会有点问题 打开SQL2005的表时超级无敌地卡。。。卡卡。。。。 怎样将多个人一起统计? 求一简单经典语句。 对带有触发器的表进行修改操作,是否成败都是同步? 关于SQL SERVER2005通过存储图片的问题 带有复杂逻辑判断的sql语句在遇到执行错误时 行列转换问题 vc中sqlserver模糊查询问题! 急急急!!!未能在sysindexs找到数据库Id9中Id对象Id1索引Id1对应的行请对sysindexs执行 怎么提取一个表当中某一字段后5位相同的记录? 时间字段增加一个月时间 邹老大在不 路过的老大们也来看看 问个比较菜的问题 update的小问题
select * from tb drop table tb
insert users select 'user1'
insert users select 'user2'
insert users select 'user3'select ID=identity(int, 1, 1), * into #T from usersselect * from #T--result
ID col1
----------- --------------------
1 user1
2 user2
3 user3
插入连续的序号