In PHP, I have an array :
[
// 'Timestamp' => 'data',
'1296001511 ' => '2',
'1295994311' => '25',
'1295965511' => '34',
'1295958311' => '32',
'1295871911' => '31',
etc.
]
In order to use these data in a chart I need to reduce the number of data by aggregating / consolidating these.
I'd like to keep jus开发者_开发百科t one value per day. In case of multiple value for one day I'd like to use an average or median value.
Difficult point : I don't have the same number of data for each day, the data set is not regular.
If it's easier I can work with SQL queries (the data is stored in a MySQL database)
If it's easier I can work with SQL queries (the data are stored in a MYSQL database)
Please do. That is what database systems are for. As for the query in MySQL, use something like this:
SELECT DATE(FROM_UNIXTIME(intcol)) thedate, AVG(datavalue) datavalue
FROM sometable
GROUP BY DATE(FROM_UNIXTIME(intcol))
精彩评论