SELECT DATE(FROM_UNIXTIME(time)) AS daygroup,
MAX(value) AS max_value,
MIN(value) AS min_value
FROM tbl
WHERE time >= UNIX_TIMESTAMP(CURDATE() - INTERVAL 7 DAY)
GROUP BY daygroup
Dette vil få minimum og maksimum af value
for hver dag inden for de seneste 7 dage.
Rediger: Opdateret løsning til at hente data for hele rækken:
SELECT a.*
FROM tbl a
INNER JOIN
(
SELECT DATE(FROM_UNIXTIME(time)) AS daygroup,
MAX(value) AS max_value
FROM tbl
WHERE time >= UNIX_TIMESTAMP(CURDATE() - INTERVAL 7 DAY)
GROUP BY daygroup
) b ON DATE(FROM_UNIXTIME(a.time)) = b.daygroup AND a.value = b.max_value