我有以下數據SQL數據透視表結合的多行
+----+-----------+---------+------+------------+-------------+------------+
| id | selection | against | runs | firstplace | secondplace | thirdplace |
+----+-----------+---------+------+------------+-------------+------------+
| 1 | a | a | 0 | 0 | 0 | 0 |
| 2 | a | b | 20 | 0 | 3 | 0 |
| 3 | a | c | 10 | 0 | 3 | 0 |
| 4 | a | d | 19 | 0 | 3 | 0 |
| 5 | b | a | 20 | 2 | 4 | 1 |
| 6 | b | b | 0 | 0 | 0 | 0 |
| 7 | b | c | 14 | 2 | 4 | 1 |
| 8 | b | d | 23 | 2 | 4 | 1 |
| 9 | c | a | 10 | 0 | 0 | 0 |
| 10 | c | b | 14 | 0 | 0 | 0 |
| 11 | c | c | 0 | 0 | 0 | 0 |
| 12 | c | d | 13 | 0 | 0 | 0 |
| 13 | d | a | 19 | 1 | 2 | 1 |
| 14 | d | b | 23 | 1 | 2 | 1 |
| 15 | d | c | 13 | 1 | 2 | 1 |
| 16 | d | d | 0 | 0 | 0 | 0 |
+----+-----------+---------+------+------------+-------------+------------+
據我瞭解,我需要以返回數據
+---+------------+-------------+------------+------------+
| | a | b | c | d |
+---+------------+-------------+------------+------------+
| a | 0 [0/0/0] | 20 [0/2/0] | 10 [0/3/0] | 19 [0/3/0] |
| b | 20 [2/4/1] | 0 [0/0/0] | 14 [2/4/1] | 23 [2/4/1] |
| c | 10 [0/0/0] | 14 [0/0/0] | 0 [0/0/0] | 13 [0/0/0] |
| d | 19 [1/2/1] | 23 [13/2/1] | 13 [1/2/1] | 0 [0/0/0] |
+---+------------+-------------+------------+------------+
創建數據透視查詢格式爲運行然後在[]中選擇第一個,第二個和第三個數據,然後根據行選擇列。
我已經查看了所有關於數據透視表的例子,但他們都有計算,只有2或3列。
我是以正確的方式處理數據透視表還是需要查看其他內容?
非常感謝。
謝謝,這幫了我很多。 –