# Cannot use non-grouped column \[sales\_manager\_name\], expected \[\]

**URL:** <https://discuss.elastic.co/t/cannot-use-non-grouped-column-sales-manager-name-expected/162331>\
**Category:** Elasticsearch\
**Created:** [December 28, 2018, 9:43am UTC](https://discuss.elastic.co/t/cannot-use-non-grouped-column-sales-manager-name-expected/162331 "2018-12-28T09:43:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gosforth](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@Gosforth](https://discuss.elastic.co/u/Gosforth)\
**Post date:** [December 28, 2018, 9:43am UTC](https://discuss.elastic.co/t/cannot-use-non-grouped-column-sales-manager-name-expected/162331/1 "2018-12-28T09:43:31Z")

</div>

What's wrong with this SQL syntax in ES:

`SELECT sum(net_value), sales_manager_name FROM "sales*"`

?

It generates error:

> Whoops! Expression failed
> 
> Expression failed with the message:
> 
> [essql] \> Unexpected error from Elasticsearch: [verification\_exception] Found 1 problem(s) line 1:45: Cannot use non-grouped column [sales\_manager\_name], expected

This is right SQL syntax.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 28, 2018, 3:29pm UTC](https://discuss.elastic.co/t/cannot-use-non-grouped-column-sales-manager-name-expected/162331/2 "2018-12-28T15:29:51Z")

</div>

What are you expecting to get in the first and the second columns here?

---

<div class="post-metadata">

**Author:** ![Gosforth](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@Gosforth](https://discuss.elastic.co/u/Gosforth)\
**Post date:** [December 31, 2018, 10:13am UTC](https://discuss.elastic.co/t/cannot-use-non-grouped-column-sales-manager-name-expected/162331/3 "2018-12-31T10:13:08Z")

</div>

> [@Gosforth](#):
>
> SELECT sum(net\_value), sales\_manager\_name FROM "sales\*"

In first number, second text.  
I've mamaged this by adding GROUP BY; `SELECT sum(net_value), sales_manager_name FROM "sales*" GROUP BY sales_manager_name`  
Original query has limited sense but is correct anyway 🙂

---

<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:** [January 28, 2019, 10:13am UTC](https://discuss.elastic.co/t/cannot-use-non-grouped-column-sales-manager-name-expected/162331/4 "2019-01-28T10:13:11Z")

</div>

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