Add Calculation Field In Query

  • Thread starter Thread starter zyus
  • Start date Start date
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]
 
Probably the best best is to use the existing query as the record source for
another query. Then do the math there.
 
Back
Top