# Elasticsearch order issue

**URL:** <https://discuss.elastic.co/t/elasticsearch-order-issue/143541>\
**Category:** Elasticsearch\
**Created:** [August 8, 2018, 2:33pm UTC](https://discuss.elastic.co/t/elasticsearch-order-issue/143541 "2018-08-08T14:33:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliyesami](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@aliyesami](https://discuss.elastic.co/u/aliyesami)\
**Post date:** [August 8, 2018, 2:33pm UTC](https://discuss.elastic.co/t/elasticsearch-order-issue/143541/1 "2018-08-08T14:33:35Z")

</div>

In the following query I want to order the total amount , how can I ?

> [elasticsearch@hadoop1 bin]$ curl -X POST [http://hadoop1:9200/\_xpack/sql?format=txt](http://hadoop1:9200/_xpack/sql?format=txt) -H 'Content-Type: application/json' -d '{"query": "SELECT acct\_num,sum(prod\_amt) total from purchase group by acct\_num order by total"}'
> 
> {"error":{"root\_cause":[{"type":"verification\_exception","reason":"Found 1 problem(s)\nline 1:78: Cannot order by non-grouped column [total], expected [acct\_num]"}],"type":"verification\_exception","reason":"Found 1 problem(s)\nline 1:78: Cannot order by non-grouped column [total], expected [acct\_num]"},"status":400}[elasticsearch@hadoop1 bin]$

---

<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:** [September 5, 2018, 2:33pm UTC](https://discuss.elastic.co/t/elasticsearch-order-issue/143541/2 "2018-09-05T14:33:48Z")

</div>

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