TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQLite SUM Function

SQLite SUM Function with history, features, advantages, installation, commands, syntax, datatypes, operators, expressions, databases, table, crud operations, clauses, like, glob, limit, and clause, advance sqlite

<< Back to SQLITE

SQLite SUM Function

The SQLite SUM function is used to return the summed value of an expression.

Syntax:

SELECT SUM(aggregate_expression)
FROM tables
[WHERE conditions]; 

Syntax when you use SUM function with GROUP BY clause:

SELECT expression1, expression2, ... expression_n
SUM(aggregate_expression)
FROM tables
[WHERE conditions]
GROUP BY expression1, expression2, ... expression_n;

Example1:

We have a table named "STUDENT", having the following data:

Sqlite Sum function 1

Retrieve total fees of the students where ID is less than or equal to 5:

SELECT SUM(FEES) AS "Total Fees"
FROM STUDENT
WHERE ID <= 5; 

Output:

Sqlite Sum function 2

Example2: Using mathematical formula with SUM function

You can use mathematical formula with SUM function.

SELECT SUM(FEES / 12) AS "Total Monthly Fees"
FROM STUDENT;

Output:

Sqlite Sum function 3

Example2: Using GROUP BY clause with SUM function:

Retrieve addresses from the table "STUDENT", find the sum of their corresponding fees and group by the result by address.

SELECT ADDRESS, SUM(FEES) AS "Total Salary"
FROM STUDENT
WHERE ID <= 5
GROUP BY ADDRESS;

Output:

Sqlite Sum function 4
Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf