本文介紹了在 SQL Server 2008 中將一些行交換為列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
SQL Server 大師的另一個...
Another one for you SQL Server gurus...
我有一張這樣的桌子...
I have a table like so...
AccountManager | Action | Count
-----------------------------------------------------
Joe | Client Negotiation | 10
Bloggs | Closing | 1
Aunty | Email | 12
Marie | Preparing Contract | 32
Action 列可能有許多不同類型的狀態,這些狀態不一定是固定的.
The Action column may have numerous different types of statuses which may not necessarily be fixed.
我需要輸出如下:
AccountManager | Client Negotiation | Closing | Email | Preparing Contract
--------------------------------------------------------------------------
Joe | 10 | 0 | 0 | 0
Bloggs | 0 | 1 | 0 | 0
Aunty | 0 | 0 | 12 | 0
Marie | 0 | 0 | 0 | 32
這是怎么實現的?幫助!
How could this be achieved? Help!
推薦答案
按照以下演練
http://www.tsqltutorials.com/pivot.php
這篇關于在 SQL Server 2008 中將一些行交換為列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!