Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Row calculations in Access

Status
Not open for further replies.

doorok

Technical User
Mar 20, 2003
10
0
0
US
I'm keeping a table of numbers products sold daily by different categories. I want to be able to calculate the sum of all the products in all categories sold by day, month, and year. Three calculations. Sales are entered into each category daily by date through an access form. The data is stored in a table by date and category. How would I do the calculations in a query or in a report.

Thank,
You
 
Here is a test scenarion with the SQL code to rollup your figures.

Table: tblSales
Fields: Category(10), ProdID Text(10), SalesAmt Number(Dbl)

Query SQL named qryProdIDSales:
Select A.Category, A.ProdID, Sum(A.SalesAmt) as TotalSalesProdID
FROM tblSales as A
GROUP BY A.Category, A.ProdID
ORDER BY A.Category, A.ProdID;

Query SQL named qryCategorySales:
Select A.Category, Sum(A.SalesAmt) as TotalSalesCategory
FROM tblSales as A
GROUP BY A.Category
ORDER BY A.Category;

Query SQL named qrySales:
Select A.Category, A.ProdID, A.TotalSalesProdID, B.TotalSalesCategory
FROM qryProdIDSales as A INNER JOIN qryCategorySales as B ON A.Category = B.Category
ORDER BY A.Category, A.ProdID;

You can run the first two queries seperately to get individual totals and then run the third one to combine the totals into one row.

Let me know if you have any problems here as I did this freehand without testing.

Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top