Reputation: 57
I'm wondering the subtraction total sum of amount_no
column of table2 from total sum of amount_no
table1.
table1 table2
|amount_no | |amount_no|
------------ -----------
|230 | |100 |
|500 | |50 |
|700 | |40 |
------------ ----------
1430 190
------------ ----------
(1430 - 190 = 1240)
SELECT ((SUM(amount_no) FROM table1) - (SELECT SUM(amount_no) FROM table2))
Upvotes: 0
Views: 53
Reputation: 6555
Updated query:
SELECT (SELECT SUM(amount_no) FROM table1) - (SELECT SUM(amount_no) FROM table2)
Your code have missing some brackets.
Upvotes: 1
Reputation: 98
Use this:
SELECT (SELECT SUM(amount_no) FROM table1) - (SELECT SUM(amount_no) FROM table2)
Your code misses the select part and minor things.
Upvotes: 3