# How to do subqueries in Kibana?

**URL:** https://discuss.elastic.co/t/how-to-do-subqueries-in-kibana/301471
**Category:** Kibana
**Tags:** kql-kibana-query-language
**Created:** [April 4, 2022, 8:23am UTC](https://discuss.elastic.co/t/how-to-do-subqueries-in-kibana/301471 "2022-04-04T08:23:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Yazid\_S](https://avatars.discourse-cdn.com/v4/letter/y/7cd45c/32.png) [@Yazid\_S](https://discuss.elastic.co/u/Yazid_S)
#### Post date: [April 4, 2022, 8:23am UTC](https://discuss.elastic.co/t/how-to-do-subqueries-in-kibana/301471/1 "2022-04-04T08:23:11Z")

</div>

Hi all,

I am exploring log files throught Kibana and I would like to extract the logs that are in error.  
My problem is that in a day, a machine can be in error in the morning and not be in error in the afternoon. So I want to extract the error logs where the machine ID is not in the list of logs that are no longer in error.

If I had to do it in SQL it would be something like SELECT id WHERE status = 'ERROR' AND id NOT IN (SELECT id WHERE status = 'SUCCESS').

Is there a Kibana query or visualization that does this kind of thing ?

---

<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: [May 2, 2022, 8:24am UTC](https://discuss.elastic.co/t/how-to-do-subqueries-in-kibana/301471/2 "2022-05-02T08:24:00Z")

</div>

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