SQL SUM() Function
The SUM() Function
The SUM() function returns the total sum of a numeric column.
SQL SUM() Syntax
| SELECT SUM(column_name) FROM table_name |
SQL SUM() Example
We have the following "Orders" table:
| O_Id |
OrderDate |
OrderPrice |
Customer |
| 1 |
2008/11/12 |
1000 |
Hansen |
| 2 |
2008/10/23 |
1600 |
Nilsen |
| 3 |
2008/09/02 |
700 |
Hansen |
| 4 |
2008/09/03 |
300 |
Hansen |
| 5 |
2008/08/30 |
2000 |
Jensen |
| 6 |
2008/10/04 |
100 |
Nilsen |
Now we want to find the sum of all "OrderPrice" fields".
We use the following SQL statement:
| SELECT SUM(OrderPrice) AS OrderTotal FROM Orders |
The result-set will look like this:
Create a free Flash website with our simple, online web design editing platform. Stunning templates
and user-friendly tools make website building easy and fun.
Start Creating your free website now!

The Altova MissionKit is an integrated suite of tools ideal for:
- XML development
- Web & Web services development
- Data mapping & integration
- Rendering & publishing XML & database data
- XBRL validation, taxonomy editing, transformation & rendering
The MissionKit for XML Developers includes XMLSpy® - the industry-leading XML editor; MapForce® - a
graphical data mapping, conversion, and integration tool; StyleVision® - a visual XSLT stylesheet designer;
DiffDog® - an XML-aware diff/merge tool; and 2 additional tools.
Try all 6 products free for 30 days!
Download a fully-functional free trial
|
|
|
|