下面是一個例子表,我有SQL語句列變換表頭
CustomerName|Items customer 1 |Item 1 customer 1 |Item 2 customer 1 |Item 3 customer 2 |Item 1 customer 2 |Item 4 customer 3 |Item 2 customer 4 |Item 5 customer 5 |Item 6
我需要的表變換到
CustomerName|Item 1|Item 2|Item 3|Item 4|Item 5|Item 6| customer 1 | X | X | X | | | | customer 2 | X | | | X | | | customer 3 | | X | | X | | | customer 4 | | | | | X | | customer 5 | | | | | | X |
我試圖PIVOT
,在SAP HANA不起作用。
任何建議將不勝感激。
只有'6'項目或者可能有更多。在這種情況下,你想在表中添加很多列嗎? – Utsav
可能有成百上千的Items :)它只是一個例子。 – Sai
請參閱http://stackoverflow.com/questions/7674786/mysql-pivot-table。 – Tom