How to select top 1 non-null record?

Hi @Anaisdg,
Is there any way to find latest non-null record ? like mysql query statement :
SELECT * FROM myTable where myTag is not null order by timestamp desc limit 1;

 Flux language would always give the range first, right ?
 |> range(start: 2022-12-10T16:00:00Z, stop: 2022-12-20T16:00:00Z)

Hello @Erikson,
Yes you are correct. This is one of the limitations of Flux. You can use |>range(start:0) to query all of your data and then use the last() function. But if you have a lot of data that will timeout, so it’s not a good solution.
But If you’re using InfluxDB Cloud you can now query with SQL.