樞需要轉換以下我想使用PIVOT將行轉換爲列。我只有數字的例子,但我需要用VARCHAR
Country , code , result
('IND','AC1','Completed'),
('IND','AC2','Completed'),
('IND','AC3','Completed'),
('SL','AC1','Status'),
('SL','AC2','ERROR'),
('AUS','AC3','Completed')
到
Country , ac1 , ac2 , ac3
------------------------
ind , Completed , Completed , Completed
sl, Status ,Error
AUS, , ,Completed
格式化你的問題,它傷害了我的眼睛,我不能讀它 – OverCoder
我刪除了不兼容的SQL代碼。但基本的想法是,你可以使用'MAX()'而不是'SUM()'來代替你爲數字工作的任何代碼。 –