Answer the question
In order to leave comments, you need to log in
How to calculate the quantity of each order, taking into account their quantity?
For example, there is such a table
id | code | qty
1 | 2324 | 2
2 | 2324 | 1
3 | 2324 | 5
4 | 2388 | 1
5 | 6311 | 12
Answer the question
In order to leave comments, you need to log in
SELECT DISTINCT code, SUM(qty) as count FROM orders GROUP BY code ORDER BY count DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question