Arithmetic Division For Two Table In Sql (postgresql)
I am trying to do a very simple division in SQL (PostgreSQL). I want to get the count of all the record from two tables, and divide them and output to another table. For example, w
Solution 1:
Well, you can use subqueries:
SELECT (SELECTCOUNT(*) FROM table1) / (SELECTCOUNT(*) FROM table2);
This does integer division. If you want a real number:
SELECT (SELECTCOUNT(*) FROM table1)::numeric/ (SELECTCOUNT(*) FROM table2);
Post a Comment for "Arithmetic Division For Two Table In Sql (postgresql)"