Sum() function in MYSQL by R4R Team

MYSQL SUM() function:
-Basically, SUM() function is return the sum of all records of the columns.

Syntax:
SELECT SUM(expression)
FROM table_name
WHERE conditions;

Display all record of table:

SELECT * FROM customer_purchase;

S.NO Item Price
1 Mango 20
2 Paste 40
3 Rice 50
4 Oil 90
5 Dairy milk 20
6 Bourbita 120

Now we find total cost of all item:

SELECT SUM(price) from Customer_purchase;

SUM(price)
340




Leave a Comment: