# Query result order

**URL:** <https://discuss.aerospike.com/t/query-result-order/3924>\
**Category:** How Aerospike Works\
**Tags:** query\
**Created:** [March 9, 2017, 9:38am UTC](https://discuss.aerospike.com/t/query-result-order/3924 "2017-03-09T09:38:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smrt28](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@smrt28](https://discuss.aerospike.com/u/smrt28)\
**Post date:** [March 9, 2017, 9:38am UTC](https://discuss.aerospike.com/t/query-result-order/3924/1 "2017-03-09T09:38:57Z")

</div>

Hi,

I would like to ask if there is an order guaranteed for the query result? Is the result sorted for instance by the key?

thx

---

<div class="post-metadata">

**Author:** ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)\
**Post date:** [May 24, 2017, 7:01am UTC](https://discuss.aerospike.com/t/query-result-order/3924/2 "2017-05-24T07:01:30Z")

</div>

I have try, the answer is no

```auto
aql> select QKEY from test.StockSnapshot where QKEY between 6002471490149800 and 6002471600000000
+------------------+
| QKEY |
+------------------+
| 6002471490162400 |
| 6002471490248800 |
| 6002471490335200 |
| 6002471490594400 |
| 6002471490680800 |
| 6002471490767200 |
| 6002471490853600 |
| 6002471490940000 |
| 6002471491372000 |
| 6002471490149800 |
| 6002471490236200 |
| 6002471490322600 |
| 6002471490581800 |
| 6002471490668200 |
| 6002471490754600 |
| 6002471490841000 |
| 6002471490927400 |
| 6002471491359400 |
| 6002471490158800 |
| 6002471490245200 |
| 6002471490331600 |
| 6002471490590800 |
| 6002471490677200 |
| 6002471490763600 |
| 6002471490850000 |
| 6002471490936400 |
| 6002471491368400 |
| 6002471490232600 |
| 6002471490319000 |
| 6002471490578200 |
| 6002471490664600 |
| 6002471490751000 |
| 6002471490837400 |
| 6002471490923800 |
| 6002471491355800 |
+------------------+
35 rows in set (0.006 secs)

```

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [May 24, 2017, 6:28pm UTC](https://discuss.aerospike.com/t/query-result-order/3924/3 "2017-05-24T18:28:08Z")

</div>

Only batch read will return in order of keys supplied. Both Secondary Indexes queries and Scans will return out of order.
