Cara paling sederhana adalah dengan union all
:
select object_tested, test_date, test_a as test, test_a_result as test_result
from table t
union all
select object_tested, test_date, test_b as test, test_b_result as test_result
from table t;
Jika Anda ingin jenis tes di output:
select object_tested, test_date, 'a' as test_type, test_a as test, test_a_result as test_result
from table t
union all
select object_tested, test_date, 'b' as test_type, test_b as test, test_b_result as test_result
from table t;
Oracle 11 juga mendukung unpivot
operator yang melakukan hal serupa. Jika Anda memiliki tabel yang sangat besar dan peduli dengan kinerja, unpivot
atau metode menggunakan join
bisa bekerja.