1
A friend created a project in Arduino that monitors power consumption in Kw/h. It every 5 minutes inserts the consumption information in the Mysql database.
Every five records I need to average them, and then take the average and multiply by 15.
I can do this in both PHP and Mysql, someone could give me a hint of how to make a listing with all the averages of 5 in 5?
This should be used to calculate the average of the last 5 readings.
SELECT AVG( consumo ) ORDER BY id DESC LIMIT 5
- Now, what’s the point of making the average to multiply? Add it all up and multiply by three, it’s the same.– Bacco
Good evening @Bacco I did,plus he’s bringing the average only 5,what I need is for it to give me an average every 5.
– Chefe Druida
@Bacco Follow select: SELECT AVG(Consumption)AS CONSUMPTION FROM Reading ORDER BY Id DESC LIMIT 5
– Chefe Druida
Do you want a listing with all the averages of 5 out of 5? it would be nice to edit the question and make it clearer if that’s it. The solution would be to add something like a GROUP BY INT(id / 5)
– Bacco