SQLite SUM() Function
Example
Return the total quantity of all the order details:
SELECT SUM(Quantity) FROM OrderDetails;
Try it Yourself »
Definition and Usage
The SUM() function returns the sum of the values in a group. NULL values are skipped.
If all the values are integers, the result is an integer. If there are no values to add, the result is NULL.
Tip: Also look at TOTAL(), AVG().
Syntax
SUM(expression)
Parameter Values
| Parameter | Description |
|---|---|
| expression | Required. A column or a calculation |
Technical Details
| Return type: | Integer or real |
|---|
More Examples
Example
Return the total quantity of each order:
SELECT OrderID, SUM(Quantity)
FROM OrderDetails
GROUP BY OrderID;
Try it Yourself »