# How I can create a Discovery view with query like

**URL:** <https://discuss.elastic.co/t/how-i-can-create-a-discovery-view-with-query-like/240113>\
**Category:** Kibana\
**Created:** [July 7, 2020, 7:46am UTC](https://discuss.elastic.co/t/how-i-can-create-a-discovery-view-with-query-like/240113 "2020-07-07T07:46:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksarkar](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@ksarkar](https://discuss.elastic.co/u/ksarkar)\
**Post date:** [July 7, 2020, 7:46am UTC](https://discuss.elastic.co/t/how-i-can-create-a-discovery-view-with-query-like/240113/1 "2020-07-07T07:46:06Z")

</div>

One of my table is getting populated by a time interval with some data from different channel with same time stamp. I wish to aggregate it w.r.t time. Sample query as below.  
`select starttime, sum(available) as available, sum(damage) as damage, sum(unavailable) as unavailable from product_inv_detail where starttime = (select max(starttime) from product_inv_detail) group by starttime;`  
This view is working properly for me in my Database. Same structure index is available in Elastic also. I am looking for a KQL to capture this data in Kibana.

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [July 7, 2020, 9:20pm UTC](https://discuss.elastic.co/t/how-i-can-create-a-discovery-view-with-query-like/240113/2 "2020-07-07T21:20:24Z")

</div>

You won't be able to do it in discover - it'll only produce a timestamp sorted list. In Visualize you'll want to use the data table.

Are all of these fields in the same document? If so - your metrics would be the select sum(damage) and sum(unavailable) portion, and the buckets would be a terms aggregation on starttime.

---

<div class="post-metadata">

**Author:** ![ksarkar](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@ksarkar](https://discuss.elastic.co/u/ksarkar)\
**Post date:** [July 8, 2020, 1:44pm UTC](https://discuss.elastic.co/t/how-i-can-create-a-discovery-view-with-query-like/240113/3 "2020-07-08T13:44:50Z")

</div>

> [@jbudz](#):
>
> and the buckets would be a terms aggregation on starttime.

Oky. Thank you.

---

<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:** [August 5, 2020, 1:44pm UTC](https://discuss.elastic.co/t/how-i-can-create-a-discovery-view-with-query-like/240113/4 "2020-08-05T13:44:51Z")

</div>

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