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:

Whether you're new to XML or already an advanced user,
the user-friendly views and powerful entry helpers,
wizards, and debuggers in XMLSpy are designed to meet your XML
and Web development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- XBRL validator & taxonomy editor
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a free trial today!
|
|
|
|