Add Calculation Field In Query

Z

zyus

I hv this sql

SELECT Qtskssubcat2.BRNCD, Qtskssubcat2.BRANCH, Qtskssubcat2.SUBCATDESC2,
Sum(Qtskssubcat2.Netbal1MIA) AS SumOfNetbal1MIA, Sum(Qtskssubcat2.Netbal2MIA)
AS SumOfNetbal2MIA, Sum(Qtskssubcat2.Netbal3MIA) AS SumOfNetbal3MIA,
Sum(Qtskssubcat2.Netbal4MIA) AS SumOfNetbal4MIA, Sum(Qtskssubcat2.Netbal5MIA)
AS SumOfNetbal5MIA, Sum(Qprevmthsubcat2.Netbal1MIA) AS SumOfNetbal1MIA1,
Sum(Qprevmthsubcat2.Netbal2MIA) AS SumOfNetbal2MIA1,
Sum(Qprevmthsubcat2.Netbal3MIA) AS SumOfNetbal3MIA1,
Sum(Qprevmthsubcat2.Netbal4MIA) AS SumOfNetbal4MIA1,
Sum(Qprevmthsubcat2.Netbal5MIA) AS SumOfNetbal5MIA1,
Sum(Qtskssubcat2.NetbalCur) AS SumOfNetbalCur, Sum(Qtskssubcat2.NetbalDelq)
AS SumOfNetbalDelq, Sum(Qtskssubcat2.NetbalNPL) AS SumOfNetbalNPL,
Sum(Qprevmthsubcat2.NetbalCur) AS SumOfNetbalCur1,
Sum(Qprevmthsubcat2.NetbalDelq) AS SumOfNetbalDelq1,
Sum(Qprevmthsubcat2.NetbalNPL) AS SumOfNetbalNPL1, Qtskssubcat2.Month,
Qtskssubcat2.YR, Qprevmthsubcat2.Month, Qprevmthsubcat2.YR,
[Qtskssubcat2].[netbaldelq]-[Qprevmthsubcat2].[netbaldelq] AS DiffNetbalDelq
FROM Qtskssubcat2 LEFT JOIN Qprevmthsubcat2 ON (Qtskssubcat2.BRANCH =
Qprevmthsubcat2.BRANCH) AND (Qtskssubcat2.SUBCATDESC2 =
Qprevmthsubcat2.SUBCATDESC2)
GROUP BY Qtskssubcat2.BRNCD, Qtskssubcat2.BRANCH, Qtskssubcat2.SUBCATDESC2,
Qtskssubcat2.Month, Qtskssubcat2.YR, Qprevmthsubcat2.Month,
Qprevmthsubcat2.YR;


Cannot run the query due to part aggregate error ...when i add in this
expression

DiffNetbalDelq: [Qtskssubcat2].[netbaldelq]-[Qprevmthsubcat2].[netbaldelq]
 
J

Jerry Whittle

Probably the best best is to use the existing query as the record source for
another query. Then do the math there.
 

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

Similar Threads


Top