create table #t2
(
k int ,
j char
)
insert into #t2
select 1,'0'
union
select 2,'0'
union
select 3,'0'
union
select 1,''
union
select 2,''
union
select 3,''
select * from #t2如何实现结果如下呢?
1 1
1 2
2 1
2 2
3 1
3 2
也就是说第一个数字一样的时候从一开始排,
例如在有一个3的话,结果是这样的
3 3
(
k int ,
j char
)
insert into #t2
select 1,'0'
union
select 2,'0'
union
select 3,'0'
union
select 1,''
union
select 2,''
union
select 3,''
select * from #t2如何实现结果如下呢?
1 1
1 2
2 1
2 2
3 1
3 2
也就是说第一个数字一样的时候从一开始排,
例如在有一个3的话,结果是这样的
3 3
(
k int,
j char
)insert into #t2
select 1,'0' union
select 2,'0' union
select 3,'0' union
select 1,'' union
select 2,'' union
select 3,''
begin trandeclare @i int
select @i=0
update #t2 set j=@i,@i=@i+1
update #t2 set j=(select count(*) from #t2 where k=a.k and j <=a.j) from #t2 aselect * from #t2
rollback trandrop table #t2
sql后面为“空”,我双击程序里的sql,出现了Error: Unable to read footer file.有谁知道这个是什么错误呢?
create table #t2
(
k int,
j char
)insert into #t2
select 1,'0' union
select 2,'0' union
select 3,'0' union
select 1,'' union
select 2,'' union
select 3,''select *,id=identity(int,1,1) into #t1 from #t2select k,j=(select count(1) from #t1 where k=a.k and id<=a.id)
from #t1 a