0% found this document useful (0 votes)
51 views

SQL AVG Function: Syntax

The SQL AVG() function returns the average value of a numeric column by ignoring NULL values. It can be used with a SELECT statement to calculate the average of a column for a table, such as calculating the average fees value from the Student table. The AVG() function can also be used with a GROUP BY clause to calculate the average value of a column for each unique value in another column, like finding the average fees for each unique student name.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

SQL AVG Function: Syntax

The SQL AVG() function returns the average value of a numeric column by ignoring NULL values. It can be used with a SELECT statement to calculate the average of a column for a table, such as calculating the average fees value from the Student table. The AVG() function can also be used with a GROUP BY clause to calculate the average value of a column for each unique value in another column, like finding the average fees for each unique student name.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL AVG() Function

SQL AVG() function returns the average value of a numeric column of a table and it ignores
NULL values during calculation.

Syntax
SELECT AVG(columnName) FROM TableName
In this article we will consider Student table to check how AVG() function works. We will
calculate average value of Fees column.
SELECT AVG(Fees) FROM Student 

So, average value of Fees column is 15766.


We can also use GROUP BY clause with AVG() function to calculate the average value as
follows.

SELECT FirstName, AVG(Fees) AS FEES FROM Student


GROUP BY FirstName
Here we are selecting FirstName column with average value of Fees column by
grouping FirstName column. So if you can observe in above output for student Gigi and
Roberto their Fees column is calculated on an average basis and returned average fees for
each one.

You might also like