0
我的數據是按以下格式:SQL Server的複雜數據透視表查詢
Customer_ID Order_ID Product_Sub-Category Product Name
=========== ======== ==================== ============
A00001 20001A Vegetables Onions
A00001 20001A Vegetables Garlic
A00002 20001B Fruits Apples
A00002 20001B Fruits Oranges
A00002 20001B Vegetables Spinach
A00003 20001C Dairy Milk
A00003 20001C Dairy Cheese
A00004 20001D Meats Lamb Chops
A00004 20001D Meats T-bone Steak
A00004 20001D Dairy Yoghurt
A00004 20001D Fruits Grapes
A00004 20001D Vegetables Garlic
我需要將其轉換成下面的格式。
Customer_ID Order_ID Vegetables Fruits Dairy Meats
=========== ======== ========== ====== ===== =====
A00001 20001A Onions, Garlic
A00002 20001B Spinach Apples, Oranges
A00003 20001C Milk, Cheese
A00004 20001D Garlic Grapes Yoghurt Lamb Chops, T-bone Steak
請讓我知道這是否可以在SQL查詢
對不起,格式化搞砸了。 –
是的,它可以做到。是的,這是一個關鍵。你做了什麼嘗試? – Santi
繁榮 - https://msdn.microsoft.com/en-us/library/ms177410.aspx,下一個問題? – Anand