日期:2014-05-17 浏览次数:20980 次
--测试数据
WITH T AS(
SELECT 'A' AS NAME,1 AS ITEM FROM DUAL UNION ALL
SELECT 'A' AS NAME,2 AS ITEM FROM DUAL UNION ALL
SELECT 'A' AS NAME,3 AS ITEM FROM DUAL UNION ALL
SELECT 'A' AS NAME,4 AS ITEM FROM DUAL UNION ALL
SELECT 'B' AS NAME,1 AS ITEM FROM DUAL UNION ALL
SELECT 'B' AS NAME,3 AS ITEM FROM DUAL UNION ALL
SELECT 'B' AS NAME,4 AS ITEM FROM DUAL UNION ALL
SELECT 'C' AS NAME,2 AS ITEM FROM DUAL
)
SELECT * FROM T;
--使用DECODE拆分行
WITH T AS(
SELECT 'A' AS NAME,1 AS ITEM FROM DUAL UNION ALL
SELECT 'A' AS NAME,2 AS ITEM FROM DUAL UNION ALL
SELECT 'A' AS NAME,3 AS ITEM FROM DUAL UNION ALL
SELECT 'A' AS NAME,4 AS ITEM FROM DUAL UNION ALL
SELECT 'B' AS