lee
lee

Reputation: 1046

mysql sum, with row IDs

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

Upvotes: 1

Views: 146

Answers (2)

Shakti Singh
Shakti Singh

Reputation: 86386

SELECT GROUP_CONCAT(id), SUM(column_name) FROM table_name GROUP BY id

Upvotes: 1

Michael Mior
Michael Mior

Reputation: 28752

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

Upvotes: 4

Related Questions