下面提到的是我的兩個查詢:SQL查詢到在PIVOT結果顯示結合
SELECT WINDOWS_NT_LOGIN, COUNT(DPS_NUMBER) as TotalDPS
FROM DispatcherProductivity
WHERE DPS_Processed_Time_Stamp>='12/04/2014 10:30 AM'
AND DPS_Processed_Time_Stamp<='12/05/2014 10:30 AM'
GROUP BY WINDOWS_NT_LOGIN
ORDER BY TotalDPS
SELECT STATUS, COUNT(DPS_NUMBER) AS TotalDPS
FROM DispatcherProductivity
WHERE DPS_Processed_Time_Stamp>='12/04/2014 10:30 AM'
AND DPS_Processed_Time_Stamp<='12/05/2014 10:30 AM'
GROUP BY STATUS
ORDER BY TotalDPS
它們各自的結果是:
WINDOWS_NT_LOGIN TotalDPS
A_S 72
T_I_S 133
STATUS TotalDPS
ID 1
Can 2
NHD 3
SED 14
Ord 185
我想獲得這一結果格式:
WINDOWS_NT_LOGIN ID Can NHD SED Ord
A_S 2 70
T_I_S 1 2 3 12 115
感謝