mysql - Want to get all data from three tables in single query with group by function -
what need: want show sales dish category
i have 3 tables problem:
1.order(dish_id,dish_price,dish_quantity) 2.dish(dish_id,dish_name,dish_cat_id) 3.dish_category(dish_cat_id,dis_cat_name
what result want : want show report , how many quantity has been sold, dish category wise , , total price , total_quantity
result expected: dish_cat_id, dish_cat_name, total_price , total_quantity_sold
what have tried:
select d.dish_name, d.dish_id, sum(o.price) total_price, sum(o.dish_quantity) total_qauntity order o , dish d o.dish_id = d.dish_id group o.dish_id
now here can dish , total price dish wise , how them dish_category wise
as right getting no idea expected fire query on selected result query them dish_category wise
select dc.dis_cat_name, sum(o.price) total_price, sum(o.dish_quantity) total_quantity order o inner join dish d on o.dish_id = d.dish_id inner join dish_category dc on dc.dish_cat_id = d.dish_cat_id group dc.dish_cat_id;
Comments
Post a Comment