Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn The AVG() Function | Aggregate Functions
Introduction to SQL

bookThe AVG() Function

AVG() returns the average value of a certain column. Let's see an example:

12
SELECT AVG(population) FROM country;
copy

AVG() can also be used to find the average of a selected set of columns or rows that meet certain conditions. Here’s an example:

123
SELECT AVG(population) FROM country WHERE population < 4478500;
copy
Task

Swipe to start coding

Write an SQL query to retrieve the average value of a surfacearea column from the country table.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 1
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain what the `AVG()` function does in more detail?

What does the `WHERE population < 4478500` condition do in the second example?

Can you show more examples of using `AVG()` with different conditions?

close

Awesome!

Completion rate improved to 2.44

bookThe AVG() Function

Swipe to show menu

AVG() returns the average value of a certain column. Let's see an example:

12
SELECT AVG(population) FROM country;
copy

AVG() can also be used to find the average of a selected set of columns or rows that meet certain conditions. Here’s an example:

123
SELECT AVG(population) FROM country WHERE population < 4478500;
copy
Task

Swipe to start coding

Write an SQL query to retrieve the average value of a surfacearea column from the country table.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 1
single

single

some-alt