15,936,876 members
See more:
SELECT SUM(`ServiceTaxAmount`) from `sale_has_enquiryitem` WHERE `ServiceTax`<>'NULL'

table1 'sale' has column 'saleamount'
table2 'purchase' has column 'purchaseamount'

as
sale purchase
saleamount purchaseamount
40 10
50 20
60 15

from above table,

40-10==30
50-20==30
60-15==45
i want to calculate total of the above difference(30+30+45=105)
Posted
Maciej Los 16-May-15 6:54am
Do not repost[^]!

## Solution 1

See my answer to your previous example of this question: how to calculate difference of two columns[^]

## Solution 2

XML
```Hi,

You have 2 different ways to achieve your goal.

1)

<pre lang="SQL">SELECT ((SELECT Sum(SaleAmount) FROM Sale) - (SELECT Sum(purchaseamount) FROM Purchase))```

2) Above query will not look nice to read. So you can separate both the queries in variables and use them

SQL
```Declare @SalesAmount money = (SELECT Sum(SaleAmount) FROM Sale)
Declare @PurchaseAmount money = (SELECT Sum(purchaseamount) FROM Purchase)

SELECT  @SalesAmount - @PurchaseAmount```

Please let me know if yo have any concern or query or if you need any other help.

Thanks