-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

ekad
  • 14,436
  • 26
  • 44
  • 46
user3903563
  • 11
  • 2
  • 7

2 Answers2

2

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

Michael Green
  • 1,397
  • 1
  • 17
  • 25
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;
Walter Mitty
  • 18,205
  • 2
  • 28
  • 58