Reputation: 401
I want to select an add up simular rows bases on one field
product amount
abc 2
abc 3
def 2
def 1
and I want as a result
Produkt Amount
abc 5
def 3
Any ideas?
Upvotes: 0
Views: 73
Reputation: 766
You need to group the table by the product and then select the name and use the aggragate function of SUM. Your query for this should look something like this:
SELECT product, SUM(amount)
FROM <TABLENAME>
GROUP BY product
Upvotes: 1
Reputation: 44601
Use sum
aggregate function with the group by
clause:
select product, sum(amount) from tbl group by product
Upvotes: 4