I am creating ecommerce website in which we get record of how many product are orders for this purpose , i am creating orders table in which product_id and quantity are save. We need sum of quantity of each product. I want query that display expected result I tried lot but can not expected result.
Order Table:
id order_details
1 Details of first order
2 Details of second order
3 Details of third order
4 Details of fourth order
Sub Order Table
id order_id product_id quantity
1 1 1 2
2 1 1 2
3 1 2 2
4 1 2 3
5 1 2 3
expected output :
product_id sum_orders_qty
1 4
2 8