Search code examples
mysqlsubtraction

MySQL arithmetic subtraction


I have a table like this:

MYSQL 
table_01            tablo_02

Calculated tax      Deductible tax
--------------      ---------------
1200                2100
2305                5200
3250                1200    
2501                3215

I want such a result

total table_01 - total table_02 = result

Solution

  • Something like this:

    select (
            select sum(calculated_tax)
            from table_01
            ) - (
            select sum(deductible_tax)
            from table_02
            ) as result