SQL Tutorial - Learn SQL




SQL Tutorial
SQL Database Table
SQL SELECT
SQL SELECT INTO
SQL DISTINCT
SQL WHERE
SQL LIKE
SQL INSERT INTO
SQL UPDATE
SQL DELETE
SQL ORDER BY
SQL OR & AND
SQL IN
SQL BETWEEN
SQL Aliases
SQL COUNT
SQL MAX
SQL MIN
SQL AVG
SQL SUM
SQL GROUP BY
SQL HAVING
SQL JOIN

Oracle Interview Questions
Cheap Study Guides
Cisco CCNA Guides
IT interview Questions
Comptia Exam Questions
MCSE Bootcamp
Oracle 10g Training
Oracle OCP Material
PMP Study Guides
Designer Perfumes




SQL SUM

The SQL SUM aggregate function allows selecting the total for a numeric column.

The SQL SUM syntax is displayed below:


SELECT SUM(Column1)
FROM Table1

We are going to use the Sales table to illustrate the use of SQL SUM clause:

Sales:

CustomerID Date SaleAmount
2 5/6/2004 $100.22
1 5/7/2004 $99.95
3 5/7/2004 $122.95
3 5/13/2004 $100.00
4 5/22/2004 $555.55

Consider the following SQL SUM statement:


SELECT SUM(SaleAmount)
FROM Sales

This SQL statement will return the sum of all SaleAmount fields and the result of it will be:

SaleAmount
$978.67

Of course you can specify search criteria using the SQL WHERE clause in your SQL SUM statement. If you want to select the total sales for customer with CustomerID = 3, you will use the following SQL SUM statement:


SELECT SUM(SaleAmount)
FROM Sales
WHERE CustomerID = 3

The result will be:

SaleAmount
$222.95



Oracle OCP Exam Guides






If you want to contact us please email to
contact @ oraclesource.net


Link to OracleSource


Bookmark OracleSource


Copyright





  © OracleSource.net. 2000-2006  



Partner Sites:  Java Interview Questions | SAP Interview Questions | Oracle DBA Interview Questions | Cisco Study Guides | CompTIA Braindumps | MCSE Braindumps | Oracle Certification | Exact Questions | IT Interview Questions | Free Oracle Training | Cheap Study Guides

Microsoft MCSE Resources  |   Cisco CCNA Resources  |   Orace OCP Resources  |   PMP Resources  |   CISSP Resources  |   Citrix Resources  |   CIW Resources  |   CompTIA A+ Resources  |   Linux Resources  |   Java SCJP Resources  |   Resources Index  |   Free Programming Tutorials