22,209
社区成员
发帖
与我相关
我的任务
分享
declare @sql varchar(5000)
select @sql='select '''+Class+''','''','''' union all ' +
'select rownumber over(order by name) NO,Name,status from tab where class='''+Class+''' union all '
from
(select distinct Class from tab) t
exec(@sql)