我不知道與MySQL。我有幾個小時試圖編寫一些與「concat組」有關的答案,以便將行數據透視到列。樞紐MySQL不工作
我的SQL:
select month(device_datetime) as month,
device_platform as platform,
count(*) as total
from devices
group by month(device_datetime), platform
order by month desc
結果是我想要的,但我想使平臺列
month | platform | total
02 | windows | 10
02 | android | 08
03 | windows | 06
04 | Macintosh| 04
我想是這樣的:
month | windows | android | macintosh
02 | 10 | 08 | 0
03 | 06 | 0 | 0
04 | 0 | 0 | 04
謝謝。我希望你可以幫助我!