I am newbie to sql, and this is my first time posting question here.
I created a table with 4 column. Item (which is Item no.) Description (the menu name) unit_price (price) and Qty (which is the order that has been made for that day).
I want the qty of every item so i write this query:
select distinct(Item),description,unit_price,qty
from cdsitem
order by item
but the problem is it doesn’t add all the qty in the specific item, it looks like this.
I want my output to become like this. the sum of quantity in every item no. and description
I hope someone can help me. Thanks
2
Answers
You want an aggregation query:
Or use the more verbose version:
select item,description,unit_price,sum(qty) as total_qty from cdsitem group by item;