jazminecat
Programmer
Hi all, I have the following query, and i need to sum the sums of three fields. Here's the SQL:
What I really need is to sum G+L+P for each CostCntr -
The records are sorted by employee, so for the above example, CostCntr #520, there are three employees.
My data looks like this:
CostCntr G L P
520 38,232 900 0
520 60,446 660 0
520 76,440 0 7560
So for this cost center I need to make the query return the sum of all of the above numbers, of 184238 for CostCntr 520.
Any insight is much appreciated!
I've tried putting the sums in like this:
but get an error, cannot have an aggregate function in expression.
Thanks in advance!
Code:
SELECT [Qry-2Empl].CostCntr, Count([Qry-2Empl].CostCntr) AS CountOfCostCntr, Sum([Qry-2Empl].GrossPay) AS G, Sum([Qry-2Empl].Long) AS L, Sum([Qry-2Empl].Prem_Amt) AS P
FROM [Qry-2Empl]
GROUP BY [Qry-2Empl].CostCntr
HAVING ((([Qry-2Empl].CostCntr)=520))
ORDER BY [Qry-2Empl].CostCntr;
What I really need is to sum G+L+P for each CostCntr -
The records are sorted by employee, so for the above example, CostCntr #520, there are three employees.
My data looks like this:
CostCntr G L P
520 38,232 900 0
520 60,446 660 0
520 76,440 0 7560
So for this cost center I need to make the query return the sum of all of the above numbers, of 184238 for CostCntr 520.
Any insight is much appreciated!
I've tried putting the sums in like this:
Code:
SELECT [Qry-2Empl].CostCntr, [Qry-2Empl].CostCntr, Sum(Sum([Qry-2Empl].GrossPay)+Sum([Qry-2Empl].Long)+Sum([Qry-2Empl].Prem_Amt)) AS Expr1
FROM [Qry-2Empl]
GROUP BY [Qry-2Empl].CostCntr, [Qry-2Empl].CostCntr
HAVING ((([Qry-2Empl].CostCntr)=520))
ORDER BY [Qry-2Empl].CostCntr;
Thanks in advance!