我有這個表SQL查詢創建跨列
customer | product | quantity
-------------------------------
CLI01 | A | 10
CLI01 | B | 20
CLI02 | A | 31
CLI03 | A | 10
CLI03 | C | 12
,我想在SQL Server中創建這樣的輸出:
customer | crossProduct | quantity
-----------------------------------
CLI01 | A+B | 30
CLI02 | Only A | 31
CLI03 | B+C | 22
在此先感謝
尼科
每2個以上的產品都有嗎? –
應該是動態的 – NikoG
[在Microsoft SQL Server 2005中模擬組\ _concat MySQL函數?](http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-microsoft-sql -server-2005) –