# Is it possible to have multiple SQL queries into the Expression Editor?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-have-multiple-sql-queries-into-the-expression-editor/333596>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [May 16, 2023, 7:16pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-multiple-sql-queries-into-the-expression-editor/333596 "2023-05-16T19:16:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamuelSMendes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samuelsmendes/32/104246_2.png) [@SamuelSMendes](https://discuss.elastic.co/u/SamuelSMendes)\
**Post date:** [May 16, 2023, 7:16pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-multiple-sql-queries-into-the-expression-editor/333596/1 "2023-05-16T19:16:08Z")

</div>

For the context, I have a query that brings me data from the last 24hous. And would like to have a second column which will deal only with information from the last 6minutes.

The thing is, if I do both like:

```auto
@timestamp" >= NOW() - INTERVAL 24 HOUR
@timestamp" >= NOW() - INTERVAL 6 MINUTE

```

It will take the data from the 24hours and only show the 6minutes of it, wont work. So I was thinking if maybe there is an option for it in expression editor. What do you guys say?

---

<div class="post-metadata">

**Author:** ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)\
**Post date:** [May 17, 2023, 3:15pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-multiple-sql-queries-into-the-expression-editor/333596/2 "2023-05-17T15:15:42Z")

</div>

Hello Samuel,

Yes, you can create a table based on the results of two essql queries, joined into one table. Just like in this example:

```auto
var_set

name="logs" value={essql "select count(*) as a from kibana_sample_data_logs"}

name="commerce" value={essql "select count(*) as b from kibana_sample_data_ecommerce"}

| createTable ids="totalA" ids="totalB"

| staticColumn name="totalA" value={var "logs" | getCell "a"}

| alterColumn column="totalA" type="number"

| staticColumn name="totalB" value={var "commerce" | getCell "b"}

| alterColumn column="totalB" type="number"

| mathColumn id="percent" name="percent" expression="totalA / totalB"

| render

```

You can read more about it [here](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html).

---

<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:** [June 14, 2023, 3:16pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-multiple-sql-queries-into-the-expression-editor/333596/3 "2023-06-14T15:16:27Z")

</div>

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