SQLite AVG function

SQLite AVG function is used to retrieve the average value of an expression.

Syntax:

Syntax when you use AVG function with GROUP BY clause:

Example1:

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

Sqlite Avg function 1

Retrieve the average fees of all students in "STUDENT" table.

Output:

Sqlite Avg function 2

Exampple2: Using DISTINCT clause with AVG function

Retrieve average distinct fees from "STUDENT" table where FEES is greater than 10000.

Output:

Sqlite Avg function 3

Example3: Using mathematical formula with AVG function

You can use mathematical formulae to retrieve an average value according to your requirement:

Output:

Sqlite Avg function 4

Example4: Using GROUP BY clause with AVG Function

Retrieve NAME and FEES from the table and GROUP BY the result by AGE:

Output:

Sqlite Avg function 5
Next TopicSQLite Count




Latest Courses