filo Posted April 4, 2014 Share Posted April 4, 2014 This is a query i have, I guess this should be easy, but.. the problem is that date is always from first row in table and not from row where max temperature is found. SELECT date, MAX(Temp) FROM table WHERE month = 04 So I guess I need a subquery SELECT ( SELECT date FROM table HAVING MAX(Temp) ), MAX(Temp) FROM table WHERE month = 04 but this does the same thing, date is always first row from table. Any help greatly appreciated Link to comment https://forums.phpfreaks.com/topic/287527-need-date-from-a-row-where-max-value-is-found/ Share on other sites More sharing options...
Barand Posted April 4, 2014 Share Posted April 4, 2014 SELECT date FROM tablename WHERE month = 4 AND temp = (SELECT MAX(temp) FROM tablename WHERE month = 4) Link to comment https://forums.phpfreaks.com/topic/287527-need-date-from-a-row-where-max-value-is-found/#findComment-1475003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.