2015. 6. 20. 22:00
http://www.w3schools.com/sql/sql_func_sum.asp
The SUM() Function
The SUM() function returns the total sum of a numeric column.
SQL SUM() Syntax
SELECT SUM(column_name) FROM table_name;
Demo Database
In this tutorial we will use the well-known Northwind sample database.
Below is a selection from the "OrderDetails" table:
OrderDetailID | OrderID | ProductID | Quantity |
---|---|---|---|
1 | 10248 | 11 | 12 |
2 | 10248 | 42 | 10 |
3 | 10248 | 72 | 5 |
4 | 10249 | 14 | 9 |
5 | 10249 | 51 | 40 |
SQL SUM() Example
The following SQL statement finds the sum of all the "Quantity" fields for the "OrderDetails" table:
'SQL' 카테고리의 다른 글
HAVING Clause (0) | 2015.06.20 |
---|---|
GROUP BY Statement (0) | 2015.06.20 |
MIN() Function (0) | 2015.06.20 |
MAX() Function (0) | 2015.06.20 |
LAST() Function (0) | 2015.06.20 |