The AVG function is a mathematical function that will calculate the average of some values that we indicate.
Sql Syntax:
-Let's create the table we will use
Script:
Check the table to see the data and the structure.
Very good
Example 1:
-will try to find the average salary of all the persons on out table.
Example 2:
-or see the average salary of all the persons that work in a specific department.
Example 3:
-or a more complex example is if we want to see the names of the persons that earn more than the average salary .
-you can see here that we have used the result of this query (select avg(salary) from test)which is a "subquery" as a condition into our (select name from test).