22,209
社区成员
发帖
与我相关
我的任务
分享
select id,
time,
log_id,
banch_id
num_id = identity(int,1,1)
into #t
from table_A
order by id,time,log_id,banch_id
go
select id,
time,
log_id,
banch_id,
min(num_id) num_id
into #t1
from #t
group by id,
time,
log_id,
banch_id
go
update #t
set num_id = a.num_id - b.num_id+1
from #t a,#t1 b
where a.id = b.id
and a.time = b.time
and a.log_id = b.log_id
and a.banch_id = b.banch_id
go
select id,
convert(char(10),time,120) as time1,
convert(char(8) ,time,108) as time2,
log_id,
banch_id,
num_id
into table_B
from #t
go