Используя функцию Oracle PIVOT, вы можете сделать это следующим образом. Вы должны поместить список всех 30 значений в часть PIVOT, что я сделал до L7:
SQL>
SQL> WITH cte_table(IDS, NAMES, LAYERS, VALUESS) as (
2 SELECT 1, 'A', 'L1', 100 from dual union all
3 SELECT 1, 'A', 'L2', 200 from dual union all
4 SELECT 1, 'A', 'L3', 300 from dual union all
5 SELECT 1, 'A', 'L4', 400 from dual union all
6 SELECT 1, 'A', 'L5', 500 from dual union all
7 SELECT 2, 'B', 'L1', 111 from dual union all
8 SELECT 2, 'B', 'L2', 222 from dual union all
9 SELECT 2, 'B', 'L3', 333 from dual union all
10 SELECT 2, 'B', 'L4', 444 from dual union all
11 SELECT 2, 'B', 'L5', 555 from dual union all
12 SELECT 2, 'B', 'L6', 666 from dual union all
13 SELECT 2, 'B', 'L7', 777 from dual)
14 SELECT *
15 FROM cte_table
16 PIVOT (MIN(VALUESS) FOR layers IN ('L1' AS "L1", 'L2' AS "L2", 'L3' AS "L3", 'L4' AS "L4", 'L5' AS "L5", 'L6' AS "L6", 'L7' AS "L7")) --list goes here
17 /
Выход:
IDS NAMES L1 L2 L3 L4 L5 L6 L7
---------- ----- ---------- ---------- ---------- ---------- ---------- ---------- ----------
1 A 100 200 300 400 500
2 B 111 222 333 444 555 666 777