I suppose you have the database name [DB-NAME].
and Columns and rows are something like.
[Table1]
ProductID Quantity Purchase Sale
----------- --------- --------- --------
1 1 24 1
2 100 50 10
If you want to calculate the [Purchase] - [Sale] for a specific Product id Use:
( Select (Purchase - Sale) AS MyNumber FROM[DB-Name].[Table1] WHERE (ProductID=1))
//where 1 is your product id
The result table will be
MyNumber
--------
23
if you want to calculate the totals for all [ProductID] Use:
(Select (SUM(Purchase) - Sum(Sale)) AS MyNumber FROM[DB-Name].[Table1] )
The result table will be
MyNumber
--------
63