[SOLVED] MYSQL average on every single day

Issue

I would like to find the averaging based on each day temperature value. How can I do so?

SELECT Timestamp, Value 
FROM aReadings 
WHERE type = 'Temperature' AND Timestamp BETWEEN ? AND ?

Solution

Try with:

SELECT DATE(Timestamp), AVG(Value)
FROM aReadings 
WHERE 
    type = 'Temperature' 
    AND Timestamp BETWEEN ? AND ?
GROUP BY DATE(Timestamp)

DATE(expr) Extracts the date part of the date or datetime expression expr.

Answered By – Federico Sierra

Answer Checked By – David Goodson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.