mysql date of min, max

Post

Posted
Rating:
#1 (In Topic #1104)
Regular
bill-lancaster is in the usergroup ‘Regular’
 I have a mysql table of temperature readings.
How can I find the date of MAX(Temperature) and the date of MIN(Temperature)?
My table looks like this:-
   EpochDate as String
   ReadingDate as Date
   Temperature as Float
   Pressure as Float
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 SELECT
    "EpochDate",
    'max' as ind
FROM yourtable
WHERE temperature = (Select Min("Temperature") from yourtable)
UNION
SELECT
    "EpochDate",
    'min' as ind
FROM youtable
WHERE temperature = (Select Max("Temperature") from yourtable);

(or whatever the equivalent SQL is in that g-awful rdbms is).
You should get the jist anyway.

Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
bill-lancaster is in the usergroup ‘Regular’
 Thanks for that, struggling to translate your query to mysql syntax.
However, there would be a problem because there could easily be several maximum temperatures with completely different dates.
I need to re-think this.
Thanks again
Online now: No Back to the top
1 guest and 0 members have just viewed this.