# Kibana querys

**URL:** <https://discuss.elastic.co/t/kibana-querys/104766>\
**Category:** Kibana\
**Created:** [October 21, 2017, 3:36pm UTC](https://discuss.elastic.co/t/kibana-querys/104766 "2017-10-21T15:36:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonic](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sonic](https://discuss.elastic.co/u/sonic)\
**Post date:** [October 21, 2017, 3:36pm UTC](https://discuss.elastic.co/t/kibana-querys/104766/1 "2017-10-21T15:36:25Z")

</div>

Hello everybody!  
I have next questions:

1. I have 3 fields: Peoples(Name) and Orders(number of orders on the website).  
One person can order 2 books, second - 3 and etc.  
I need to count, how many orders person has and visualize it in datatable with his ID.  
How can I do it in kibana?  
2)Can I make a query in kibana, like in sql, using WHERE, GROUP BY,Count,If and etc.  
Many thanks!

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [October 23, 2017, 4:41pm UTC](https://discuss.elastic.co/t/kibana-querys/104766/2 "2017-10-23T16:41:29Z")

</div>

Hello Sergey,

Elasticsearch is not a SQL database, so you cannot just use SQL queries (though there are efforts to build a layer, that accepts SQL plugins - though that doesn't mean that will ever be possible inside Kibana).

In Elasticsearch you work a lot with aggregation to aggregate (GROUP BY) your data together, and with filters and queries to filter it (WHERE).

What you are looking into is most likely, doing a _terms aggregation_ on the _customer\_id_ (or whatever it's called) field. That way you would get the count of documents for each customer\_id. If you have a field in there with the actual _amount_ that was ordered, instead of using the count aggregation as a metrics aggregation, you could switch to a _sum_ aggregation on that field. Now the value wouldn't be the amount of documents, but the actual sum of all orders in those documents.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![sonic](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sonic](https://discuss.elastic.co/u/sonic)\
**Post date:** [October 24, 2017, 10:35am UTC](https://discuss.elastic.co/t/kibana-querys/104766/3 "2017-10-24T10:35:49Z")

</div>

Thank you Tim for reply!  
I already found an easy way to do it)

---

<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:** [November 21, 2017, 10:36am UTC](https://discuss.elastic.co/t/kibana-querys/104766/4 "2017-11-21T10:36:15Z")

</div>

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