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.
What the query has to do is to calculate the balance for every day in the month, sum up the amounts and then divide it by the number of days in the current month. If there is no transaction on a given day, the balance stays the same.
The avg() function has the following syntax: SELECT AVG( column_name ) FROM table_name; The avg() function can be used with the SELECT query for retrieving data from a table.
The AVG() function returns the average value of a numeric column.
If you only want a total count of sales every month, then you can use COUNT function instead. mysql> select year(order_date),month(order_date),sum(sale) from sales WHERE condition group by year(order_date),month(order_date) order by year(order_date),month(order_date);
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With