34,587
社区成员
发帖
与我相关
我的任务
分享
加个自增列
select *,id=identity(int,1,1) into #tb from tb
select * ,(select count(1) from #tb where 票号=t.票号 and id<=t.id) from #tb t
select 票号,序号=(select count(*) from #yscc2
where 票号 = a.票号 and 产品编号<= a.产品编号)
,产品编号,数量
from #yscc2 a
order by1,2