"Data points outside time range" on subquery

Hi guys,

I get a message saying “data points outside time range” when doing a subquery.

The original query

SELECT last(“km”) FROM “metrics” WHERE $timeFilter GROUP BY “drive” fill(previous)

works just fine, but when I put

SELECT sum(“drives”) from (SELECT last(“km”) AS “drives” FROM “metrics” WHERE $timeFilter GROUP BY “drive” fill(none))

I get above error. Putting the hover tooltip shows that there is a value (which also seems correct).

Any help would be much appreciated!

Cheers

1 Like

you need a group by time on the outer query as well, your just summing and returning a single value in the outer query I think.

Not an expert in InfluxDB sub queries. Try using the query inspector (introduced in Grafana v4.6 in metrics tab) to inspect the response from influxdb.

For me also same error was coming but then i appended “Where $timefilter” in the outer query it worked for me.

eg.
SELECT sum(coveredFieldsCount)/sum(specFieldsCount)*100 as Coverage from (SELECT LAST(“specFieldsCount”) as specFieldsCount, LAST(“coveredFieldsCount”) as coveredFieldsCount FROM “apitestagent_apicoverage_metadata” WHERE (“businessPurpose” =~ /^business/ ) AND $timeFilter GROUP BY “apiId” order by asc) WHERE $timeFilter