;WITH cte AS (SELECt SeekId, CatId, ct.Name, ROW_NUMBER() OVER (PARTITION BY SeekId ORDER BY CatId) AS RN FROM MySeekCatTable sk JOIN CatTable ct ON sk.CatId = ct.CatId)SELECt SeekId, MAX(CASE WHEN RN = 1 THEN Name END) AS A, MAX(CASE WHEN RN = 2 THEN Name END) AS B, MAX(CASE WHEN RN = 3 THEN Name END) AS CFROM cteGROUP BY SeekId
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)