Averaging data for each day
Posted: Mon Nov 29, 2004 11:14 am
How can I work out the average of the following:
Users enter in various figures into a MySQL database (the type is unimportant other than they are integers) at various times of the day. The number of figures entered for each day could vary from none to 24.
so for example, a user could have entered the following data;
27 Nov 10:00 - 120
27 Nov 13:00 - 130
27 Nov 16:00 - 125
27 Nov 22:00 - 135
28 Nov 06:00 - 140
28 Nov 20:00 - 115
28 Nov 23:00 - 135
30 Nov 18:00 - 160
How can I query the database selecting all the data entered but then averaging the figures for each day.
Using the example above I would want to show the following:
Average figures:
27 Nov = 130
28 Nov = 130
30 Nov = 160
I'm ok with using array_sum() and count() to average the figures but can't figure out how to group them into days.
Thanks in advance
Users enter in various figures into a MySQL database (the type is unimportant other than they are integers) at various times of the day. The number of figures entered for each day could vary from none to 24.
so for example, a user could have entered the following data;
27 Nov 10:00 - 120
27 Nov 13:00 - 130
27 Nov 16:00 - 125
27 Nov 22:00 - 135
28 Nov 06:00 - 140
28 Nov 20:00 - 115
28 Nov 23:00 - 135
30 Nov 18:00 - 160
How can I query the database selecting all the data entered but then averaging the figures for each day.
Using the example above I would want to show the following:
Average figures:
27 Nov = 130
28 Nov = 130
30 Nov = 160
I'm ok with using array_sum() and count() to average the figures but can't figure out how to group them into days.
Thanks in advance