排序,小问题不简单,大家援手! Select *,(Select count(*) from 表 where shift = a.shift and wno <= a.wno) as [order]from 表 a 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Select *,(select sum(1) from 表 where shift=tem.shift and wno<=tem.wno) [order] from 表 tem Select *,(Select count(*) from 表 where shift = a.shift and wno <= a.wno) as [order]from 表 a 各位已答对了,但我的问题依然没有解决,其实问题应该是这样的: A01 A01 A01 A01 A01 R01 R01 R01 R01 只有一列:想得到 A01 1 A01 2 A01 3 A01 4 A01 5 R01 1 R01 2 R01 3 R01 4谢谢啦! 只有一个字段,那就再加一个字段再说。Select f1,identity(int,1,1) as iid into #tmp from 表Select f1,(Select sum(1) from #tmp where f1 = a.f1 and iid<= a.iid) as id from #tmp a 你的问题跟我问的一样,在不允许用临时表等条件下,直接用一个SQL语句添加一个递增列,我问了很多人都不知道该如何写。:) Select shift,(select sum(1) from 表 where shift=tem.shift and wno<=tem.wno) [order] from 表 tem?? 求一个SQL语句!谢谢!!!!!! sql server 行变列问题 sp_cursoropen 实现分页问题 怎么把2005的实例转到2000上? 疑难问题请教!!!!! 设计表索引的时候,应该怎么考虑? 请教如何将SQL Server2005中的TB数据库中的A表的owner角色提升为dbo 角色? 急急!!!access导入到MS-SQL SERVER 2000数据库的问题! 关于时间格式输入的问题! sqlserver排序的问题 请问:sql server里如何将数据从表里取出并同时给几个变量赋值 关于排序的再问!
from 表 a
A01
A01
A01
A01
A01
R01
R01
R01
R01
只有一列:想得到
A01 1
A01 2
A01 3
A01 4
A01 5
R01 1
R01 2
R01 3
R01 4谢谢啦!
Select f1,identity(int,1,1) as iid into #tmp from 表
Select f1,(Select sum(1) from #tmp where f1 = a.f1 and iid<= a.iid) as id from #tmp a
??