I have 2 tables
- product
id | designation |
---|---|
1 | coca |
2 | Pepsi |
3 | Fanta |
4 | Seven |
5 | Eight |
2)sub_product
product_id | name | quantity |
---|---|---|
1 | sm | 10 |
1 | lg | 10 |
1 | xl | 20 |
2 | 1L | 10 |
2 | 2L | 20 |
2 | 5L | 20 |
3 | Ty | 10 |
3 | Sa | 20 |
4 | ha | 20 |
4 | kd | 30 |
what I wanna have is this: the designation from the product table and total quantity which represent the SUM of the quantity that have the same product_id
designation | total quantity |
---|---|
Coca | 40 |
Pepsi | 50 |
Fanta | 30 |
Seven | 50 |
Notes : I use SQL server