1

In MySQL I'm trying to sum up a column but retain the row IDs. When I do a sum, the IDs are compressed and the result is

1 | 1500

What I would like is

1,2,3 | 1500

lee
  • 1,036
  • 2
  • 14
  • 24

2 Answers2

4

SELECT GROUP_CONCAT(id), SUM(value) FROM table

Michael Mior
  • 28,107
  • 9
  • 89
  • 113
1
SELECT GROUP_CONCAT(id), SUM(column_name) FROM table_name GROUP BY id
Shakti Singh
  • 84,385
  • 21
  • 134
  • 153
  • I'm getting a [BLOB - 5B] under the GROUP_CONCAT column. Found from http://stackoverflow.com/questions/2133936/using-group-concat-in-phpmyadmin-will-show-the-result-as-blob-3b that GROUP_CONCAT expects value to be a string. Any issues with using `GROUP_CONCAT(CAST(id AS CHAR))` ? – lee Oct 18 '11 at 05:57