I have a table called products, it has a column called products_price with 10000+ different prices, I want to add all the prices together. How can this be done?
Asked
Active
Viewed 1,475 times
1 Answers
1
Most SQL implementations (including MySQL) support special select operators. In your case, you'd do something like
SELECT SUM('products_price') from 'products';
Easy :)
by the way, I don't know what you've googled, but really, this solution kind of hits you right in the face as soon as you type "Mysql column sum" into googles search bar.

Marcus Müller
- 34,677
- 4
- 53
- 94
-
it doesnt work, error #1064 - You have an error in your SQL syntax; ''products'' at line 1 – John Feb 10 '15 at 17:33
-
works fine for me; compare http://stackoverflow.com/questions/4586040/mysql-sum-elements-of-a-column – Marcus Müller Feb 10 '15 at 17:35
-
nothing to do with it. Are you sure you're actually don't have a typo somewhere. – Marcus Müller Feb 10 '15 at 17:43
-
I copied and pasted your command so no typo. the table is called products and the column I want to sum is called products_price. I just want to add all the prices together in that column. thanks – John Feb 10 '15 at 17:53
-
try removing the `'`. – Marcus Müller Feb 10 '15 at 18:02
-
This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available. – John Feb 10 '15 at 18:04
-
yes without the quotes it works but gave an error, anyway now I have the total. thanks – John Feb 10 '15 at 18:05