Sql Sum

You use Sql Sum to add up values of a numeric column. The keyword 'Distinct' works for this function, it will ignore the Null values in the calculation.

The syntax:

SELECT SUM(column_name)
FROM   table_name 

Example: Let's use a simple table to illustrate. Expenses table, find out how much spent so far.

ExpIdDateDescriptionCategoryAmount
10011/07/2009 12:00:00 AMLong Black Coffee13.00
10021/07/2009 12:00:00 AMNewspaper51.00
10031/07/2009 12:00:00 AMMorning Tea14.00
10041/07/2009 12:00:00 AMLunch18.00
10051/07/2009 12:00:00 AMDinner112.00
10061/07/2009 12:00:00 AMMagazine PC World511.00

SQL statement:

SELECT SUM(amount) AS total
FROM   expenses 

The result:

Total
39.00

Quick link. From here, you can learn the following:

Sql Select
The core of Sql, selecting data from table.

Sql Where
Conditionally selecting rows from table.

Sql Distinct
Eliminating duplicate values in the output.

Sql Count
Counting number of rows.

Sql Max
This function will return the highest value.

Sql Min
This function will return the lowest value.

Sql Avg
This function will return the average value.

Sql Order By
Sorting the output

Sql And Or
Connecting two or more conditions in the Where or Having clause.

Sql Group By
Grouping rows into sets.

Sql Having
To filter the result of aggregation

Sql Like
Pattern searching for conditions in Where or Having clause

Sql Between
Added to conditions to show results between two values.

Journey
Buy at AllPosters.com
A bend in the road is not the end of the road... unless you fail to make the turn

Positive Resources

All of us have at least two or three things that excite us. We could talk about these subjects for hours. Good news!. Did you know that Site Built It! can turn this type of deep interest and enthusiasm into a revenue-generating business?

Review some of the Site Build It! case studies and you'll absolutely discover something that ignites more positive ideas into your mind.

SBI! Video Tour


Invest the most
important 30 minutes
you will spend online.

Click, sit back, and
understand why SBI!
makes you succeed.