0

I've come across a problem that I don't really know how to solve. I have a table which looks somewhat like this:

ID   Name     Price     Quantity
1    BookA      5         10
2    BookB     10         15
3    BookA     15         15
4    BookA      5         25

How could I join rows which have same Name, same Price and sum Quantity? So it would look like this:

ID   Name     Price     Quantity
1    BookA      5         35
2    BookB     10         15
3    BookA     15         15

Thank you in advance!

1
  • 3
    Hint: GROUP BY. SUM(). Commented Apr 8, 2020 at 13:57

1 Answer 1

1

This is just a simple GROUP BY query:

SELECT Min(ID), Name, Price, Sum(Quantity) as Quantity
FROM yourtable
GROUP BY Name, Price;
Sign up to request clarification or add additional context in comments.

1 Comment

This is what I was looking for! Thank you, Sir

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.