SQLite SUM Function

The SUM function in SQLite is an Aggregate Function used to find the sum of all non-NULL values in a column. The output of the SUM function is mostly an integer if all the non-null values present in that column are integers. If the values are mixed (Integer and Non-Integers) then the result will be in float. If the SUM function is used on a column that consists of only NULL values or has only one row that is NULL / Empty, it will not throw any error, but it will return NULL as output, not 0.

SQLite SUM() Function

SQLite is an embedded database that doesn’t use a database like Oracle in the background to operate. It is written in C language and is used by developers who embed a lightweight database over the existing application, browser, or embedded systems. The main features of SQLite are that it is a tiny, quick, self-contained, reliable, full-featured SQL database engine.

In this article, we will understand the SUM Function in SQLite in detail along with some practical examples and so on.

Similar Reads

SQLite SUM Function

The SUM function in SQLite is an Aggregate Function used to find the sum of all non-NULL values in a column. The output of the SUM function is mostly an integer if all the non-null values present in that column are integers. If the values are mixed (Integer and Non-Integers) then the result will be in float. If the SUM function is used on a column that consists of only NULL values or has only one row that is NULL / Empty, it will not throw any error, but it will return NULL as output, not 0....

Examples of SQLite SUM Function

To understand the SUM function we will use some table to perform various operations and queries. Here we have the employees table which consists of empID, DeptID, FirstName, LastName, Salary, and Location as Columns. After inserting some data into the table....

Conclusion

In this article, we saw how the SUM function of SQLite can be used for various purpose, from finding the total sum of integers to Joining different tables together and sorting out results using the HAVING and GROUP BY clause. The SUM Aggregate function is a very useful function when it comes to Arithmetical Tasks and sorting out based on arithmetical conditions....

Contact Us