# MYSQL SUM Function

Category : TECH Author : Ankur Rastogi Date : Sat Jun 04 2016 Views : 70

### MYSQL Sum Overview

MYSQL SUM() function returns the aggregated summation of all the values for input column name. There are lot of real scenario application uses for MYSQL SUM function like calculate total population of a state by finding sum of its city wise population. Other use can be to find out the total salary given by company by finding out the sum of all the employee's salary.

Other use case of MYSQL Sum function can be suppose in one table you have list of purchased goods than you can use mysql sum function to calculate price of all the goods. Later we will see more examples

We also wrote about some of the other mysql functions

### Mysql Sum Syntax

Syntax for MYSQL SUM function is

*SELECT SUM(column_name) FROM hostel_list;*

### MYSQL Sum Examples

Let us understand MYSQL SUM function better with the help of an example

Consider table hostel_list which contains hostel_list details

+----+-------------------+-----------+----------+

| id | name | occupancy | capacity |

+----+-------------------+-----------+----------+

| 1 | ASHOK BHAVAN | 2 | 1090 |

| 2 | KAILASH BHAVAN | 2 | 990 |

| 3 | RUDRAKSH BHAVAN | 2 | 990 |

| 4 | KAVERI BHAVAN | 1 | 690 |

| 5 | BHAGIRATHI BHAVAN | 4 | 2140 |

| 6 | NARMADA BHAVAN | 6 | 3240 |

| 7 | GANGA BHAVAN | 1 | 780 |

| 8 | YAMUNA BHAVAN | 8 | 4580 |

+----+-------------------+-----------+----------+

#### MYSQL Sum Function Example Case 1:

Let us find the total hostel capacities, MYSQL query for that will be

SELECT SUM(capacity) FROM hostel_list;

+---------------+

| SUM(capacity) |

+---------------+

| 14500 |

+---------------+

#### MYSQL SUM Function Example Case 2:

Suppose we want to find out the total number of occupancy college has, than we can find out by using sql query

SELECT SUM(occupancy) FROM hostel_list;

+----------------+

| SUM(occupancy) |

+----------------+

| 26 |

+----------------+

1 row in set (0.01 sec)

### MYSQL Sum Overview

MYSQL SUM() function returns the aggregated summation of all the values for input column name. There are lot of real scenario application uses for MYSQL SUM function like calculate total population of a state by finding sum of its city wise population. Other use can be to find out the total salary given by company by finding out the sum of all the employee's salary.

Other use case of MYSQL Sum function can be suppose in one table you have list of purchased goods than you can use mysql sum function to calculate price of all the goods. Later we will see more examples

We also wrote about some of the other mysql functions

### Mysql Sum Syntax

Syntax for MYSQL SUM function is

*SELECT SUM(column_name) FROM hostel_list;*

### MYSQL Sum Examples

Let us understand MYSQL SUM function better with the help of an example

Consider table hostel_list which contains hostel_list details

+----+-------------------+-----------+----------+

| id | name | occupancy | capacity |

+----+-------------------+-----------+----------+

| 1 | ASHOK BHAVAN | 2 | 1090 |

| 2 | KAILASH BHAVAN | 2 | 990 |

| 3 | RUDRAKSH BHAVAN | 2 | 990 |

| 4 | KAVERI BHAVAN | 1 | 690 |

| 5 | BHAGIRATHI BHAVAN | 4 | 2140 |

| 6 | NARMADA BHAVAN | 6 | 3240 |

| 7 | GANGA BHAVAN | 1 | 780 |

| 8 | YAMUNA BHAVAN | 8 | 4580 |

+----+-------------------+-----------+----------+

#### MYSQL Sum Function Example Case 1:

Let us find the total hostel capacities, MYSQL query for that will be

SELECT SUM(capacity) FROM hostel_list;

+---------------+

| SUM(capacity) |

+---------------+

| 14500 |

+---------------+

#### MYSQL SUM Function Example Case 2:

Suppose we want to find out the total number of occupancy college has, than we can find out by using sql query

SELECT SUM(occupancy) FROM hostel_list;

+----------------+

| SUM(occupancy) |

+----------------+

| 26 |

+----------------+

1 row in set (0.01 sec)

**Disclaimer:** The above content reflect author’s personal views and do not reflect the views of OYEWIKI. Neither OYEWIKI nor any person/organization acting on its behalf is liable to accept any legal liability/responsibility for any error/mislead in this information or any information available on the website. This website in no way accepts the responsibility for any loss, injury, damage, discomfort or inconvenience caused as a result of reliance on any information provided on this website.

If you want to add more comments to the article or you see any thing incorrect please write a comment below and we will surely get back to you.