求一SQL语句,在固定行中为表添加一个临时编号,其余行置空
create table test(clothid varchar(10),number varchar(10),bagid varchar(10))
insert into test
select '11-11','56','1'
union all select '11-12-1','45','1'
union all select '11-12-2','46','1'
union all select '11-12-3','50','2'
union all select '11-13-1','60','2'
union all select '11-13-2','32','2'
union all select '11-14','34','3'
union all select '11-15-1','45','3'
union all select '11-15-2','52','3'
结果如下:
id number bagid clothid
1 56 1 11-11
2 45 1 11-12-1
3 46 1 11-12-2
4
5
1 50 2 11-12-3
2 60 2 11-13-1
3 32 2 11-13-2
4
5
1 34 3 11-14
2 45 3 11-15-1
3 52 3 11-15-2
4
5
4,5可以显示也可以不显示,请问这样可以实现吗
问题点数:40、回复次数:1Top
1 楼yjdn(人形机器)回复于 2005-06-04 18:20:27 得分 40
--楼主,还没解决吗?不是说4,5也可不以不显示的吗?
select id=(select count(*) from test where left(bagid+clothid,3)=left(a.bagid+a.clothid,3) and clothid<=a.clothid)
, number ,bagid,clothid
from test aTop




