0

I have a large MySQL table that includes events as rows. Each row has a description and a corresponding value. The titles are duplicated throughout however and I would like to deduplicate them and sum together their values in PHP.

For example, if I have:

Title 1, 10
Title 1, 20
Title 2, 10
Title 3, 5
Title 3, 20

I would like to end up with:

Title 1, 30
Title 2, 10
Title 3, 25

Help greatly appreciated.

Shehary
  • 9,926
  • 10
  • 42
  • 71
  • 1
    select title,sum(numthing) from tablex group by title order by title – Drew Aug 10 '15 at 23:57
  • Hi Guys, I had tried mostly a PHP approach with `unique_array` being my erroneous starting point, but @Drew, thank you so much for simplifying my approach, and unsticking my late night stick! I am a relative beginner, so excuse the lack of etiquette in not showing my original working. – danmtslatter Aug 11 '15 at 01:34

0 Answers0