Exclude the highest value(s) from max()

Hi!

I have a dashboard to show me the high, low and average temperature of each day.

Now I had to bring the Zigbee Sensor inside to replace the battery or to reconnect it to the network several times. There are now one or two datapoints taken inside of the house so the statistic for that day is not useful anymore (forgot to turn of the logging in Node Red).

Is it possible to omit the top X values? My SQL knowledge is not that good and I could not find a viable solution online. I know that this is not 100% accurate but the only one who uses this is me anyway :wink:

SELECT max("temperature") FROM "outside" WHERE $timeFilter GROUP BY time(24h)

Thanks!

Hi,

You can use nested sql queries like :

SELECT MAX(field) from Table where field != (select Max(field) from table)

Did you try something like this (check the syntax first :slight_smile:

Good Luck