doujia7094 2014-08-21 10:13
浏览 53

mysql计算行数并按月分组[重复]

This question already has an answer here:

I have a table called cc_calls and there I have many call records I want to count them and group them in months I have a timestamp called starttime and I can use that row to extract the month, also limit the count for 12 months

the results should be like:

Month       Count

January     768768
February    876786
March       987979
April       765765
May         898797
June        876876
July        786575
August      765765
September   689787
October     765879
November    897989
December    876876

Can anyone guide me or show me the mysql query that I need to get this result.

</div>
  • 写回答

2条回答 默认 最新

  • douyin6188 2014-08-21 10:18
    关注
    SELECT
    MONTH(starttime),
    COUNT(*)
    FROM cc_calls
    GROUP BY MONTH(starttime)
    

    Be aware though, that this counts for each month of every year. You might want to include the year in the select and group by clauses or filter for a specific year in the where clause.

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能