-1
create view top5food as
select f.FoodID,f.FoodName,SUM(o.Quantity) as "Total Food Sold"
from  FOODANDBEVERAGEORDER o,FOODANDBEVERAGE f
where o.foodid=f.foodid
group by o.foodid
order by SUM(o.Quantity) desc;

anything wrong with this query? there is an error ORA-00979 NOT A GROUP BY EXPRESSION

0

2 Answers 2

2

You have f.FoodName in the select list but it is not in the group by clause.

Sign up to request clarification or add additional context in comments.

that means i need to add f.FoodName in the group by clause also ?
Yes you should add that column to the group by.
0
create view top5food as
select f.FoodID,f.FoodName,SUM(o.Quantity) as "Total Food Sold"
from  FOODANDBEVERAGEORDER o,FOODANDBEVERAGE f
where o.foodid=f.foodid
group by f.FoodID, f.FoodName
order by SUM(o.Quantity) desc;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.