mysql date of min, max

Post your Gambas programming questions here.
Post Reply
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

mysql date of min, max

Post by bill-lancaster »

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
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: mysql date of min, max

Post by thatbruce »

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.
Have you ever noticed that software is never advertised using the adjective "spreadable".
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: mysql date of min, max

Post by bill-lancaster »

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
Post Reply