Skip to content
Advertisement

SQL. Average entries per month

I have some abstract entry in DB and it’s creation date. How can I get average entries created per month?

Edit:

Table has Name field and CreationDate field.

Advertisement

Answer

SELECT count(*) AS count, MONTH(date_column) as mnth
FROM table_name
GROUP BY mnth

Should work for you

Edit:

SELECT AVG(a.count) AS avg 
FROM ( SELECT count(*) AS count, MONTH(date_column) as mnth
       FROM table_name
       GROUP BY mnth) AS a
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement