Summing Totals in Query (1 Viewer)

DerekDaNoob

Registered User.
Local time
Today, 22:45
I am having trouble summing totals on a query

I need to group by IngredientID and have the total for that ingredient added up. Then sorted highest to lowest
 

Attachments

  • IMAG1113.jpg
    IMAG1113.jpg
    98.7 KB · Views: 78

DerekDaNoob

Registered User.
Local time
Today, 22:45
Thanks for the reply
Code:
SELECT [Meal - Recipes IngredientListQ].MealID, [Meal - Recipes IngredientListQ].IngredientID, [Meal - Recipes IngredientListQ].IngredientName, Sum([Meal - Recipes IngredientListQ].Qty) AS SumOfQty
FROM [Meal - Recipes IngredientListQ]
GROUP BY [Meal - Recipes IngredientListQ].MealID, [Meal - Recipes IngredientListQ].IngredientID, [Meal - Recipes IngredientListQ].IngredientName, [Meal - Recipes IngredientListQ].ID
ORDER BY [Meal - Recipes IngredientListQ].IngredientName, Sum([Meal - Recipes IngredientListQ].Qty) DESC;
 

plog

Banishment Pending
Local time
Today, 07:45
Demonstrate your issue with data please. Provide 2 sets of data:

A: starting data from your table(s). Include table and field names and enough data to cover all cases.

B. expected results from A. Show what you expect to end up with when you feed in the data from A.
 

Ranman256

Well-known member
Local time
Today, 08:45
Remove the
GROUP BY [Meal - Recipes IngredientListQ].ID

you dont want to group this. ID shouldnt be in the query.
 

almahmood

Registered User.
Local time
Today, 18:15
Try this:

SELECT [Meal - Recipes IngredientListQ].MealID, [Meal - Recipes IngredientListQ].IngredientID, [Meal - Recipes IngredientListQ].IngredientName, Sum([Meal - Recipes IngredientListQ].Qty) AS SumOfQty
FROM [Meal - Recipes IngredientListQ]
GROUP BY [Meal - Recipes IngredientListQ].MealID, [Meal - Recipes IngredientListQ].IngredientID, [Meal - Recipes IngredientListQ].IngredientName
ORDER BY [Meal - Recipes IngredientListQ].IngredientName, Sum([Meal - Recipes IngredientListQ].Qty) DESC;
 

Users who are viewing this thread

Top Bottom