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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping in a Query

Status
Not open for further replies.

sha123

Programmer
Nov 13, 2002
58
ZA
I have a dbase where we get our recipes from, I now created a query to get the weighted averages but I want to group the ingredients when I run the report.

Here ia an example of the table:
Date |Ingredient|OrderQty|Weight|Qty/Lug|Waste|Exp1|Expr2|
01/08| Onions | 10 | 0.20 | 6 | 80 | 60 |5.40 |
02/08| Onions | 5 | 0.30 | 4 | 60 | 20 |3.20 |

I now need only a report that says Onions(Once) and then does all my calculations

But on that report there may be upto 10 products - and I need the calculations by product
 
You must break this into two queries...

The first query should query for all entries matching the ingredient that you want such as "onions" along with the values that you want to average...Don't get the date because you can't group on this.

ex qry1: SELECT Ingred, FieldsToAvg FROM Table WHERE Ingred = "Ingredient"

The second query should query the first query that you created. Now you just avg the fields that you want grouping on the ingredient that you want.

ex qry 2: SELECT Ingred, Avg(FieldToAvg) As Averaged FROM qry1 GROUP BY Ingred

You get the idea..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top