select max(case when seqnum % 10 = 0 then number end) as number_1,
max(case when seqnum % 10 = 1 then number end) as number_2,
. . .
max(case when seqnum % 10 = 9 then number end) as number_10
from (select t.*,
row_number() over (order by newid()) - 1 as seqnum
from t
) t
group by floor(seqnum / 10)
1条答案
按热度按时间qmb5sa221#
可以使用条件聚合和
row_number()
: