Calculation In Query

Z

zyus

My query to calculate difference in net_bal of two tables

SELECT Sum([Tbl-PreviousMONTH].NET_BAL) AS SumOfNET_BAL,
Sum([Tbl-SKS].NET_BAL) AS SumOfNET_BAL1,
Sum([Tbl-PreviousMONTH].[net_bal]-[tbl-sks].[net_bal]) AS Diff
FROM [Tbl-PreviousMONTH] INNER JOIN [Tbl-SKS] ON [Tbl-PreviousMONTH].ACNO =
[Tbl-SKS].ACNO
WHERE ((([Tbl-PreviousMONTH].NPLFLG)="N" Or ([Tbl-PreviousMONTH].NPLFLG) Is
Null) AND (([Tbl-PreviousMONTH].ARRMTH) Not Between 1 And 5));

As a result i will get this

Sumofnet_bal Sumofnetbal1 Diff
1,000,000 900,000 100,000

The diff is the net figure derived from the calculation. Is there a way to
calculate how much in total the positive amount and the negative amount that
derived to 100,000 nett.

TQ
 
K

KARL DEWEY

Try it this way --
(Sum([Tbl-PreviousMONTH].[net_bal]) - Sum([tbl-sks].[net_bal])) AS Diff

Or maybe you are wanting this --
Abs(Sum([Tbl-PreviousMONTH].[net_bal]) - Sum([tbl-sks].[net_bal])) AS Diff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top