105
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:
Retrieve the average fees of all students in “STUDENT” table.
Output:
Exampple2: Using DISTINCT clause with AVG function
Retrieve average distinct fees from “STUDENT” table where FEES is greater than 10000.
Output:
Example3: Using mathematical formula with AVG function
You can use mathematical formulae to retrieve an average value according to your requirement:
Output:
Example4: Using GROUP BY clause with AVG Function
Retrieve NAME and FEES from the table and GROUP BY the result by AGE:
Output:
Next TopicSQLite Count