I have a table that contains random data against a key with duplicate entries. I'm looking to remove the duplicates (a projection as it is called in relational algebra), but rather than discarding the attached data, sum it together. For example:
orderID    cost
 1          5
 1          2
 1          10
 2          3
 2          3
 3          15
Should remove duplicates from orderID whilst summing each orderID's values:
orderID    cost
 1          17       (5 + 2 + 10)
 2          6
 3          15
My assumption is I'd use SELECT DISTINCT somehow, but I don't know how I'd go about doing so. I understand GROUP BY might be able to do something but I am unsure.
 
     
    