我不知道与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
谢谢。我希望你可以帮助我!