Total() function

total() function returns the total or sum of all values of the column.

Syntax: total(name_of_the_column)

Python3




# import the sqlite module
import sqlite3
  
# establishing a connection to the database
connection   = sqlite3.connect("sales.db")
  
# creating a cursor object
cursor = connection.cursor()
  
# total monthly_sale
Total_mon_sale= "select total(monthly_sale) from sales1"
cursor.execute(Total_mon_sale)
  
# Print the total score
print("The total monthly sale of all items is:")
  
print(cursor.fetchone()[0])
  
# Closing database connection
connection.close()


Output:

The total monthly sale of all items is:
26230.0

Using SQLite Aggregate functions in Python

In this article, we are going to see how to use the aggregate function in SQLite Python. An aggregate function is a database management function that groups the values of numerous rows into a single summary value. Average (i.e., arithmetic mean), sum, max, min, Count are common aggregation functions. SQLite provides us with many aggregate functions used for statistical analysis. 

Database for demonstration: To download the database click here.

Similar Reads

Max() function

max() function returns the maximum value of all the values from the column we specified....

Min() function

...

Avg() function

min() function returns the minimum value of the all the values from the column we specified....

Total() function

...

Sum() function

avg() function returns the average or arithmetic mean of all the values in the column we specify. If any null value is there in the column it’s left out....

Count() function

...