答案 0 :(得分:1)
如果没有要转动的列,则无法进行转动,但您可以创建要转动的列。这样的事情应该可行:
SELECT Rownum, [Australia], [India], [United States]
FROM
(SELECT ROW_NUMBER() OVER(PARTITION BY Country, ORDER BY City) AS Rownum, Country, City
FROM vw_Country
) sourcetable
PIVOT
(
MIN(City)
FOR Country IN ([Australia], [India], [United States])
) AS pvt
ORDER BY pvt.Rownum
答案 1 :(得分:0)
使用rank创建另一列,然后使用pivot。
Select [Australia], [India], [United States]
from
(
select Country, City,
Rank() over (partition by country order by city) as rnk
from yourTable
) src
pivot
(
Max(City)
for Country in ([Australia], [India], [United States])
) piv;