Raju Sah
Raju Sah

Reputation: 600

Addition & Subtraction multiple column from multiple TABLES POSTGRES

select total_claim-total_release;

Result = (100+50) - (75+25) = 50

Upvotes: 0

Views: 137

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522741

Just inline the subqueries and do the arithmetic:

SELECT
    (SELECT SUM(col_claim) FROM table1) +
    (SELECT SUM(col_claim) FROM table2) -
    (SELECT SUM(col_release) FROM table3) -
    (SELECT SUM(col_release_two) FROM table4) AS result;

Upvotes: 1

Related Questions