# Database query using select provide erratic results

**URL:** <https://discuss.elastic.co/t/database-query-using-select-provide-erratic-results/208367>\
**Category:** Elasticsearch\
**Created:** [November 18, 2019, 6:10pm UTC](https://discuss.elastic.co/t/database-query-using-select-provide-erratic-results/208367 "2019-11-18T18:10:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saxojp](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@saxojp](https://discuss.elastic.co/u/saxojp)\
**Post date:** [November 18, 2019, 6:10pm UTC](https://discuss.elastic.co/t/database-query-using-select-provide-erratic-results/208367/1 "2019-11-18T18:10:22Z")

</div>

Hi,

I have issues with the erratic behavior of select statements were the result of a first request will return nothing. But if I run the same statement immediately the database return the correct result.

Here is an example of an select statement that I use:

SELECT avg("active.sessions") AS result  
FROM "snmp-\*"  
WHERE "@timestamp" \>= now() - INTERVAL 5 minutes  
AND hostname = 'my-host'  
AND collector = 'col-01'  
HAVING result BETWEEN 1000 AND 5000

If the system has been sitting idle for a couple of minutes I will receive a nothing but if I re-run the select statement immediately the I get the right answer.

Any body have an idea of what is wrong!

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 16, 2019, 6:10pm UTC](https://discuss.elastic.co/t/database-query-using-select-provide-erratic-results/208367/2 "2019-12-16T18:10:23Z")

</div>

Closed on December 16, 2019, 6:10pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
