Group by STRING and sum another field as you group <p>I just recently got a job maintaining an app that stores some products in a table. In the table there is the quantity of the product. There are a random number of records in the table so one product could have 1 to n records inside. Because I wasn't designing the app someone made the table this way, (If it was me, I'd create a new table just for products then group by id, would work great I presume, but I cant change it now.). Now I have a problem since I never did this before (Not on MSSQL and not on SQLite for that matter). How would you group by product name and sum the quantity of grouped items? </p> <p>This doesn't work but probabbly I can be more clear what i want:</p> <pre><code>SELECT Name, Quantity FROM products GROUP BY Name </code></pre> <p>(there is SUM somewhere here, but if I put sum on quantity this will probabbly just return the sum of all quantities not just the ones grouped.</p> <p>Another example (these are records in the table):</p> <pre><code>NAME Quantity ItemA 1 ItemA 7 ItemB 8 ItemC 1 ItemB 2 </code></pre> <p>The desired result of the query to fetch all elements but grouped would be:</p> <pre><code>ItemA 8 ItemB 10 ItemC 1 </code></pre>