MIN() working, but, MAX() is not

I’ve looked over the syntax 10s of times now, and can’t seem to figure out what’s going on. I’m trying to get the min and max values of column “pressure1” from table Sensor.

I’ve run both of the following queries in phpMysql

This works and gives me the accurate minimum value over the past 24hours:

SELECT CONVERT_TZ(reading_time,'US/Mountain','US/Central') as reading_time, pressure1 FROM Sensor WHERE pressure1=(select MIN(pressure1) FROM Sensor) AND reading_time > now() - INTERVAL 1 DAY LIMIT 1 

This however returns zero rows:

SELECT CONVERT_TZ(reading_time,'US/Mountain','US/Central') as reading_time, pressure1 FROM Sensor WHERE pressure1=(select MAX(pressure1) FROM Sensor) AND reading_time > now() - INTERVAL 1 DAY LIMIT 1 

I know this is something easy I’m missing here – but I can’t make my eyes see it? And it was working up until today.

submitted by /u/huskyvarnish
[link] [comments]


Go to Source of this post
Author Of this post: /u/huskyvarnish
Title Of post: MIN() working, but, MAX() is not
Author Link: {authorlink}