Filter days where some value is constant all day long

I have different devices which give me a value (let’s call it val) at different times of the day. For each device I would like to get all entries where this value is constant (or less than some fixed value, say 10) throughout the day.

With
SELECT * FROM (SELECT max(val) AS mx FROM measurement WHERE ("DevName" = 'dev1') GROUP BY time(1d) fill(null)) WHERE mx=0
I can get the max value for a single device for each day, but I don’t know how to continue from here.

Any suggestions?

Hello @diophantus7,
Welcome! What version of InfluxDB are you using?

Thanks @Anaisdg! I am using version 1.8.

Hello @diophantus7,
If you’re willing to enable Flux…

…you can do:

from(bucket: "cpu")
  |> range(start: -30d, stop:now())
  |> filter(fn: (r) => r["_measurement"] == "measurement")
  |> filter(fn: (r) => r._value <= 10.0)