# SQL Dividing 2 values from 2 queries in CANVAS

**URL:** <https://discuss.elastic.co/t/sql-dividing-2-values-from-2-queries-in-canvas/222381>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [March 5, 2020, 10:58pm UTC](https://discuss.elastic.co/t/sql-dividing-2-values-from-2-queries-in-canvas/222381 "2020-03-05T22:58:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)\
**Post date:** [March 12, 2020, 1:43pm UTC](https://discuss.elastic.co/t/sql-dividing-2-values-from-2-queries-in-canvas/222381/2 "2020-03-12T13:43:33Z")

</div>

Hey @AlfredoC, so you can't do this directly in the SQL but you should be able to accomplish it using the `math` and `string` expression functions. Here is a link to the Canvas expression documentation: [https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html)

Here is another Discuss post that answers a similar question: [Kibana Canvas , Calculate percentage using to aggregations](https://discuss.elastic.co/t/kibana-canvas-calculate-percentage-using-to-aggregations/190702/4)

The important bit is:

```auto
| essql 
    query="SELECT order_date, customer_gender FROM \"kibana_sample_data_ecommerce\""
    count=10000
| math { 
    string "count(customer_gender)/" 
      {filters group="order_date" ungrouped=true 
       | essql query="SELECT order_date, customer_gender FROM \"kibana_sample_data_ecommerce\""
           count=10000
       | math "count(customer_gender)"
      } 
  }

```

---

_[View the full topic](https://discuss.elastic.co/t/sql-dividing-2-values-from-2-queries-in-canvas/222381)._
