标签:数据 .com order by 列转行 sel image code com 技术
表中数据列转行
SELECT PEOPLE_NAME,
MAX(DECODE(RN, 1, ILL_NAME, NULL)) AS ILL_NAME1,
MAX(DECODE(RN, 2, ILL_NAME, NULL)) AS ILL_NAME2,
MAX(DECODE(RN, 3, ILL_NAME, NULL)) AS ILL_NAME3,
MAX(DECODE(RN, 4, ILL_NAME, NULL)) AS ILL_NAME4
FROM (SELECT A.PEOPLE_NAME,
A.ILL_NAME,
ROW_NUMBER() OVER(PARTITION BY PEOPLE_NAME ORDER BY ILL_NAME) AS RN
FROM ILL_NAME A) T
GROUP BY PEOPLE_NAME
ORDER BY 1
标签:数据 .com order by 列转行 sel image code com 技术
原文地址:https://www.cnblogs.com/ZyZx/p/9946685.html