Take the 2-minute tour ×

I have a table with hourly temperatures:

id   timestamp   temperature

I want to select the highest temperature AND the corresponding timestamp for each day.

select max(temperature), timestamp from table group by date(from_unixtime(timestamp))

does not work because it always returns the timestamp of the first row (but I need the timestamp from the row with the highest temperature).

Any suggestions would be greatly appreciated.

share|improve this question

1 Answer 1

Try this one....

select max(temperature), timestamp from temp group by UNIX_TIMESTAMP(date(timestamp));
share|improve this answer
date() does not work for unix timestamps... –  Daniel Jul 18 '13 at 12:19

Your Answer


