Transact SQL查询-枢轴-SQL

Transact SQL查询-枢轴-SQL,第1张

Transact SQL查询-枢轴-SQL
;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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4990344.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存