Home Sql Mysql-example MySQL Addition

Related Tutorials


 
 

Share on Google+Share on Google+

MySQL Addition

Advertisement
MySQL Addition returns you the sum value of the total counts in a table. The Aggregate function is used to perform the calculation in SQL Query.

MySQL Addition

     

MySQL Addition returns you the sum value of the total counts in a table. The Aggregate function is used to perform the calculation in SQL Query. We make use of Aggregate function with group by and order by.

 Understand with Example

The Tutorial illustrate an example from 'MySQL Addition'. To understand the example we have a table employee in the database. The select order by query is used to sort the records by specific column. In this example we sorts the records of name and salary on the basis of salary column from table 'employee'.

 

 

 

Query

 

select name, salary from employee order by salary;

 

Output

 

+------------------------+--------+
| name                   | salary |
+------------------------+--------+
| Miss.hardeep           | 5000   |
| Mr.komal choudhary     | 5000   |
| Mr.girish tewari       | 5000   |
| Mr.sandeep kumar suman | 6000   |
| Mr.govind              | 6000   |
| Mr.vineet bansal       | 6000   |
| Miss.anusmita          | 6000   |
| Mr.amit raghuvanshi    | 6000   |
| Mr.santosh kashyap     | 7500   |
| Mr.amardeep patel      | 8000   |
| Mr.vikash              | 8500   |
| Mr.vinod kumar         | 8500   |
| Mr.ravi kant           | 10000  |
| Mr.rakesh              | 12000  |
| Mr.noor                | 13500  |
| Mr.deepak mohanty      | 15000  |
| Mr.vimlaksha gautam    | 15000  |
| Mr.suman saurabh       | 17000  |
+------------------------+--------+

 

In this example the sum keyword is used to calculate the salary of employee in a table 'employee'.

Query

 

 select sum(salary) from employee;

 

Output

 

+-------------+
| sum(salary) |
+-------------+
| 160000      |
+-------------+

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 4, 2009

Related Tutorials

Discuss: MySQL Addition  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com