我有两列,第一列是我想要排名前10位的产品(1-10)
那是
SELECT TOP 10 * FROM Product
在第二列中,我想要接下来的10个结果(11-20)
我怎么做?
WITH T AS ( SELECT TOP 20 name, row_number() OVER (ORDER BY id) AS RN FROM Products ORDER BY id ) SELECT MAX(CASE WHEN RN <=10 THEN name END) AS Col1, MAX(CASE WHEN RN > 10 THEN name END) AS Col2 FROM T GROUP BY RN % 10