Is it possible to add two sql queries together? as they both output a number i want to add them up
Hi @louisc
You can use CTE https://www.metabase.com/learn/sql-questions/sql-cte or Sub-Query https://www.metabase.com/docs/latest/users-guide/referencing-saved-questions-in-queries.html
ok thanks @flamber and how can I add two questions results together?
@louisc
You can do something like this, which is not specific to Metabase.
select (select count(*)::float from table1) * (select count(*)::float from table2)
If that doesn't work for you, then:
Post "Diagnostic Info" from Admin > Troubleshooting
And your two queries.
I have done that:
select (select count() from orders_order where is_order_authorized = 'true'and is_order_using_elyn = 'true') / (select count() from orders_order where 1=1 and is_order_using_elyn = 'true')
but the result is still 0
@louisc Try running that query directly on your database. Most databases returns an integer instead of a float for count
, so you'll need to cast it as float.
it works fine on the database
@louisc Post "Diagnostic Info" from Admin > Troubleshooting.