0

I want to ask about how to count the number of data with several different variables in a column, for example I have data like this:

Example Data

how to calculate the quantity of mangoes and apples that have been taken?

3

1 Answer 1

1

You can use group by clause and then can apply sum function over it.

Select Item, Sum(Quantity) from TableName group by Item;

and to rename the new column you can use as

Select Item, Sum(Quantity) as 'Total' from TableName group by Item;

to get only quantity of mangoes and apples you can use where clause

Select Item, Sum(Quantity) as 'Total' from TableName where Item in ('Apple', 'Mango') group by Item;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.