sql2000的bug?
实际应用中偶然发现,@@version为8.0.194
declare @tmp table (id1 int identity(1,1),id int,nid int,fday int,fexp nvarchar(50))--nid为用于最后排序输出,fday为日期,先插入各天业务,再计算各天发生额与余额,再计算月发生额与余额--最后按日期排序输出。declare @tmp1 table (id int)insert into @tmp (id,nid,fday,fexp)select 1,0,1,'业务'union all select 1,0,1,'业务' union all select 1,0,1,'业务'union all select 1,0,2,'业务' union all select 1,0,2,'业务'union all select 1,0,2,'业务' union all select 1,0,2,'业务'union all select 1,0,3,'业务' union all select 1,0,3,'业务'union all select 1,0,5,'业务' union all select 1,0,5,'业务'union all select 1,0,5,'业务' union all select 1,0,8,'业务'union all select 1,0,8,'业务' union all select 1,0,8,'业务'union all select 1,0,8,'业务' union all select 1,0,9,'业务'union all select 1,0,9,'业务' union all select 1,0,10,'业务'union all select 1,0,10,'业务' union all select 1,0,10,'业务'union all select 1,0,11,'业务' union all select 1,0,12,'业务'union all select 1,0,12,'业务' union all select 1,0,12,'业务'union all select 1,1,1,'本日发生额与余额' union all select 1,1,2,'本日发生额与余额'union all select 1,1,3,'本日发生额与余额' union all select 1,1,5,'本日发生额与余额'union all select 1,1,8,'本日发生额与余额' union all select 1,1,9,'本日发生额与余额'union all select 1,1,10,'本日发生额与余额' union all select 1,1,11,'本日发生额与余额'union all select 1,1,12,'本日发生额与余额' union all select 1,2,31,'本月发生额与余额'insert into @tmp1 values (1)select a.id,a.id1,count(*) nidfrom @tmp a,@tmp b,@tmp1 cwhere a.id=b.id and a.id=c.id and (a.fday>b.fday or a.fday=b.fday and a.nid>b.nid or a.fday=b.fday and a.nid=b.nid and a.id1>=b.id1)group by a.id,a.id1order by 1,3update aaset nid=bb.nidfrom @tmp aa, ( select a.id,a.id1,count(*) nidfrom @tmp a,@tmp b,@tmp1 cwhere a.id=b.id and a.id=c.id and (a.fday>b.fday or a.fday=b.fday and a.nid>b.nid or a.fday=b.fday and a.nid=b.nid and a.id1>=b.id1)group by a.id,a.id1) bbwhere aa.id=bb.id and aa.id1=bb.id1--update后输出结果不正确,nid不是子查询的连续整数。select * from @tmp order by id,nid
id id1 nid----------- ----------- -----------1 1 11 2 21 3 31 26 41 4 51 5 61 6 71 7 81 27 91 8 101 9 111 28 121 10 131 11 141 12 151 29 161 13 171 14 181 15 191 16 201 30 211 17 221 18 231 31 241 19 251 20 261 21 271 32 281 22 291 33 301 23 311 24 321 25 331 34 341 35 35(35 行受影响)(35 行受影响)id1 id nid fday fexp----------- ----------- ----------- ----------- --------------------------------------------------1 1 1 1 业务2 1 2 1 业务3 1 2 1 业务26 1 2 1 本日发生额与余额27 1 5 2 本日发生额与余额4 1 5 2 业务5 1 5 2 业务6 1 5 2 业务7 1 5 2 业务8 1 10 3 业务9 1 10 3 业务28 1 10 3 本日发生额与余额29 1 13 5 本日发生额与余额10 1 13 5 业务11 1 13 5 业务12 1 13 5 业务13 1 17 8 业务14 1 17 8 业务15 1 17 8 业务16 1 17 8 业务30 1 17 8 本日发生额与余额31 1 22 9 本日发生额与余额17 1 22 9 业务18 1 22 9 业务19 1 25 10 业务20 1 25 10 业务21 1 25 10 业务32 1 25 10 本日发生额与余额22 1 29 11 业务33 1 29 11 本日发生额与余额34 1 31 12 本日发生额与余额23 1 31 12 业务24 1 31 12 业务25 1 31 12 业务35 1 35 31 本月发生额与余额(35 行受影响)
select @@version/*Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)(所影响的行数为 1 行)*/
[解决办法]
a.fday>b.fday or a.fday=b.fday and a.nid>b.nid or a.fday=b.fday and a.nid=b.nid and a.id1>=b.id1
[解决办法]
--查看一下版本select @@version
[解决办法]
语句有问题!
可能是and or运算符的问题!
[解决办法]
只能学习了
[解决办法]
sql2008 运行正常,估计是写法哪里不太规范吧
[解决办法]
up.........
[解决办法]
不懂 没环境。
[解决办法]
支持。。。。。。。。。
[解决办法]
学习....
[解决办法]
[解决办法]
[解决办法]
非常不错,感觉给我带来了启示!
[解决办法]
看不懂
[解决办法]
sql2000 sp4测试正常
[解决办法]
看不懂
[解决办法]
[解决办法]
内容存入剪贴板
[解决办法]
努力学习中
[解决办法]
学习了
[解决办法]
学习~~
[解决办法]
2000没用过
[解决办法]
2000很少用
[解决办法]
怎么还有个鞋子的广告?
[解决办法]
学学啊
[解决办法]
关注中
[解决办法]
这么老的东西都有问题。。。先给自己接10分
[解决办法]
sqlsever2000不打sp4就是个超级垃圾,bug海了去了.
[解决办法]
2000的版本还是别怀疑Bug了,基本不会有。
[解决办法]
cong zi shen zhao yuanyin
[解决办法]
都是高手啊
[解决办法]
真是高手来着的
[解决办法]