1
我有一個表(表A)是主鍵選擇獲取3行數據與3列(可樂,COLB,COLC)</p> <p>可樂COLB 3分不同的列
select *
from TableA
where ColA = '001';
給我這
COLA COLB COLC
---- ----- --------
001 AA1 460
001 AB1 380
001 AC1 950
我需要這個結果在這個格式
COLA AA1 AB1 AC1
----------- ----------- ----------- -----------
001 460 380 950
即所有結果行成一列到不同的對應列。
PIVOT是你在找什麼:) .. https://oracle-base.com/articles/11g/pivot -and-unpivot-operators-11gr1 – William
搜索'數據透視表' – HoneyBadger
[Oracle數據透視運算符]的可能重複(http://stackoverflow.com/questions/19280591/oracle-pivot-operator) –