WITH TEST AS(SELECT 1 AS Id, '苹果汁' AS NAME FROM Dual UNION ALLSELECT 2 AS Id, '牛奶' AS NAME FROM Dual UNION ALLSELECT 3 AS Id, '蕃茄酱' AS NAME FROM Dual UNION ALLSELECT 4 AS Id, '盐' AS NAME FROM Dual UNION ALLSELECT 5 AS Id, '麻油' AS NAME FROM Dual UNION ALLSELECT 6 AS Id, '酱油' AS NAME FROM Dual UNION ALLSELECT 7 AS Id, '海鲜粉' AS NAME FROM Dual UNION ALLSELECT 8 AS Id, '胡椒粉' AS NAME FROM Dual UNION ALLSELECT 9 AS Id, '鸡' AS NAME FROM Dual UNION ALLSELECT 10 AS Id, '蟹' AS NAME FROM Dual UNION ALLSELECT 11 AS Id, '民众奶酪' AS NAME FROM Dual UNION ALLSELECT 12 AS Id, '德国奶酪' AS NAME FROM Dual UNION ALLSELECT 13 AS Id, '龙虾' AS NAME FROM Dual UNION ALLSELECT 14 AS Id, '沙茶' AS NAME FROM Dual UNION ALLSELECT 15 AS Id, '味精' AS NAME FROM Dual UNION ALLSELECT 16 AS Id, '饼干' AS NAME FROM Dual UNION ALLSELECT 17 AS Id, '猪肉' AS NAME FROM Dual UNION ALLSELECT 18 AS Id, '墨鱼' AS NAME FROM Dual UNION ALLSELECT 19 AS Id, '糖果' AS NAME FROM Dual UNION ALLSELECT 20 AS Id, '桂花糕' AS NAME FROM Dual UNION ALLSELECT 21 AS Id, '花生' AS NAME FROM Dual UNION ALLSELECT 22 AS Id, '糯米' AS NAME FROM Dual)SELECT MAX(Decode(MOD(Id, 3), 1, Id, '')) Id1,MAX(Decode(MOD(Id, 3), 1, NAME, '')) Name1,MAX(Decode(MOD(Id, 3), 2, Id, '')) Id2,MAX(Decode(MOD(Id, 3), 2, NAME, '')) Name2,MAX(Decode(MOD(Id, 3), 0, Id, '')) Id3,MAX(Decode(MOD(Id, 3), 0, NAME, '')) Name3FROM TestGROUP BY Trunc(Rownum / 3 - 0.1, 0)ORDER BY Id1 |