DSum in Query

  • Thread starter Thread starter D
  • Start date Start date
D

D

In my query, I have a field: New_Cost:[AllocatedCost]+[Base]

I need to get the Total of that column and divide by each record [New_Cost]
to come up with a percentage in a new field -- New_Cost_Percentage.

Can this be done and if so, how?
 
SELECT itemID,
SUM(qty) AS totalForThisItem,
SUM(qty) / (SELECT SUM(qty) FROM myTable) AS percentage
FROM myTable
GROUP BY itemID


is an example about how you can do it (in SQL view of the query). change the
table name and the fields name (any thing which is not all cap), as
appropriate for your case.


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top