您无需对说明做任何事情,说明也随标签而有所不同。它没有聚合,因此在隐式“ group by”中,因此您在结果集中获得了单独的行。
您也可以使用另一个(虚拟)聚合来捕获它:
select * from ( select * from TEST2 where tag in ('LN', 'SN'))PIVOT( max(value) as value, max(description) as description for tag in ('LN' as ln, 'SN' as sn))order by category, subcat, item, "Date";Date SUBCAT CATEGOR IT LN_VALUE LN_DEscriptION SN_VALUE SN_DEscriptION--------- ------ ------- -- ----------------- --------------- ----------------- ---------------24-OCT-13 290223 1219576 25 1105618Lot Number 3x12mm Serial Number 24-OCT-13 290223 1219576 28 1303757Lot Number 18-JUN-15 354506 1219576 4 1403114Lot Number 18-JUN-15 354506 1219576 9 7777777777 Lot Number 9.999999999999E12 Serial Number或者,如果不想使用它,可以通过指定您想要的列而不是使用,将其从中间结果集中排除
*:
select * from ( select category, subcat, item, "Date", tag, value from TEST2 where tag in ('LN', 'SN'))PIVOT( max(value) for tag in ('LN' as ln, 'SN' as sn))order by category, subcat, item, "Date";CATEGOR SUBCAT IT Date LN SN ------- ------ -- --------- ----------------- -----------------1219576 290223 25 24-OCT-13 11056183x12mm1219576 290223 28 24-OCT-13 1303757 1219576 354506 4 18-JUN-15 1403114 1219576 354506 9 18-JUN-15 7777777777 9.999999999999E12


