3

I have a legacy table with unnormalized column evaluation that has values like 8, 5, 9 or 7, 6. How do I explode these string by comma and sum the value using SQL?

assignments table:
id | evaluation
---|------------
1  | 7,6,8
2  | 3,2

desired result:
id | score
---|------------
1  | 21
2  | 5
randomor
  • 5,329
  • 4
  • 46
  • 68
  • Just go through this link: http://stackoverflow.com/questions/21567706/how-to-sum-a-comma-separated-string-in-sql – VJ Hil Jun 10 '14 at 20:08
  • Do it in your application level code i.e php for future first consider [**Database_normalization**](http://en.wikipedia.org/wiki/Database_normalization) – M Khalid Junaid Jun 10 '14 at 20:19
  • Thanks for the pointer. I wasn't able to find that question before asking. It looks like I do have to have privilege to do stored procedures though. – randomor Jun 10 '14 at 20:51

0 Answers0