SQL 分组产生序号

 

SQL 分组产生序号

 update x set x.HiddenNo='TT'+CONVERT(varchar(12),y.GenTime,112)+RIGHT('0000'+CAST(Y.Rw AS nvarchar(50)),4) from  XXXXXXAAAAAA x join (
 select a.Guid,a.GenTime, ROW_NUMBER() OVER(partition by 'XCYH'+CONVERT(varchar(12),a.GenTime,112)  ORDER BY a.GenTime ) Rw from XXXXXXAAAAAA  a join XXXXXXBBBBB b
on a.Guid=b.Guid
 where HiddenNo is null) y
 on x.Guid=y.Guid

 

posted @ 2020-06-23 11:21  三瑞  阅读(402)  评论(0编辑  收藏  举报