基于另一列的SQL Dynamic Pivot

时间:2018-10-09 21:08:02

标签: sql-server pivot row-number

我有以下查询

SELECT TOP 10
    pkRowId AS [Row Guid],
    fkItemId AS [Item Guid],
    SortOrder AS [SortOrder],
    IsMain,
    Updated,
    REPLACE(Url, 'i.ebayimg.com', 'ecx-images.amazon.com') AS [Url],
    ROW_NUMBER() OVER (PARTITION BY fkItemId ORDER BY SortOrder) AS [Row Number]
FROM 
    [download].[item_image] 

以以下格式显示数据:

Input

我希望以以下格式显示:

Result

如何旋转源,以便Url1在IsMain为true的地方显示Url?

0 个答案:

没有答案