1

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.

Felix Geenen
  • 2,465
  • 1
  • 28
  • 37
Johan H.
  • 157
  • 3
  • 14

2 Answers2

2
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.

fancyPants
  • 50,732
  • 33
  • 89
  • 96
0
SELECT
MONTH(starttime),
COUNT(*)
FROM cc_calls
GROUP BY (MONTH(FROM_UNIXTIME(starttime)))