Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
MySQL Addition 
 

MySQL Addition returns you the sum value of a specific column for a group in a table.

 

MySQL Addition

                         

MySQL Addition returns you the sum value of a specific column for a group in a table. The Aggregate function sum() is used to perform the addition in SQL Query. We can make use of Aggregate function with group by and order by clause.

Syntax:

SUM([DISTINCT] column_name):

Returns the sum of the values of the column column_name. If there are no rows then SUM() returns NULL. The DISTINCT keyword can be used to sum only the distinct values of the column.

Understand with Example

The Tutorial illustrates an example of '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 sort 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 |
+--------+--------+
| Kamal  | 101    |
| Ajay   | 105    |
| Nitin  | 110    |
| Rajiv  | 120    |
| Vinay  | 130    |
| Sachin | 150    |
| Karan  | 160    |
+--------+--------+

In this example, the sum() function is used to calculate sum of salary of all employees in a table 'employee'.

Query

 

 select sum(salary) from employee;

 

Output

 

+-------------+
| sum(salary) |
+-------------+
| 876         |
+-------------+

 

                         

» View all related tutorials
Related Tags: sql mysql c query syntax ant reference sed display range limit number int tar start show if for poi ie

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.