Use result of Select as condition

Hello,
I’m stuck and would be grateful for help:
I have a measurement like this:

time sequence record_nr


1594283547000000000 0 0
1594283622000000000 0 1
1594283721000000000 1 0
1594283757000000000 1 1
1594283805000000000 1 2

I wan’t to visualize the record_nr in a Grafana-graph, but only those from the last sequence.
So the query has to use the results of another query like this:
SELECT record_nr FROM “measurement” WHERE sequence = (SELECT last(“sequence”) FROM “measurement”);

thanks in advance

Influx query language may look like standard SQL, but it isn’t (quite) :slight_smile:

Try:

SELECT record_nr FROM “measurement” WHERE last = (SELECT last(“sequence”) FROM
“measurement”);

Antony.

thanks for the answer, unfortunately it doesn’t work that way either
influx accepts no SELECT after the =

Sorry - my brain was doing something else when I wrote that :frowning:

Try:

SELECT record_nr FROM (SELECT last(“sequence”) FROM “measurement”) WHERE
sequence = last

Antony.

mh, no errors but also no results with this query

There’s something wrong with me today :frowning:

select record_nr from (select last(sequence), record_nr from measurement)

I do wonder whether you in fact want to have a “group by” in there, though, to
make it a bit more meaningful?

Maybe tell us what results you expect from your original table and the query
you wanted to perform?

Antony.

Thanks, now I get a result, but only the last row. I need to have all rows with sequence = 1…
The challenge is to have two graphs in Grafana, one graph with all record numbers and one graph only with the record numbers of the last sequence