Here is what my table looks like:
Here what I need:
I tried this code
SELECT DISTINCT(product_id),
SUM(quantity) OVER (PARTITION BY product_id) AS sumquantity
FROM ord1;
CodePudding user response:
GROUP BY will do the trick in this case!
SELECT emp, name, product, SUM(quantity)
FROM ord1
GROUP BY emp, name, product
ORDER BY emp, name, product
Replace the column names with the ones from your database table.