How do I get the sum of all the distinct items? e.g. 0001 equals 10
and 0002 equals 10
.
What could be the best possible (MySQL or Laravel Query Builder) query on the sample data provided below.
tbl_transactions
:
+-------+-----------+-----------+
| id | item_code | quantity |
+-------+-----------+-----------+
| 1 | 0001 | 6 |
| 2 | 0001 | 4 |
| 3 | 0002 | 7 |
| 4 | 0002 | 3 |
+-------+-----------+-----------+