Course Content
Introduction to SQL
Introduction to SQL
The AVG() Function
AVG()
returns the average value of a certain column.
Let's see an example:
SELECT AVG(population) FROM country;
AVG()
can also determine the average of specific columns or rows (with some conditions). Let's take a look at the following example:
SELECT AVG(population) FROM country WHERE population < 4478500;
Task
Write an SQL query to retrieve the average value of a surfacearea
column from the country table.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Thanks for your feedback!
The AVG() Function
AVG()
returns the average value of a certain column.
Let's see an example:
SELECT AVG(population) FROM country;
AVG()
can also determine the average of specific columns or rows (with some conditions). Let's take a look at the following example:
SELECT AVG(population) FROM country WHERE population < 4478500;
Task
Write an SQL query to retrieve the average value of a surfacearea
column from the country table.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Thanks for your feedback!
The AVG() Function
AVG()
returns the average value of a certain column.
Let's see an example:
SELECT AVG(population) FROM country;
AVG()
can also determine the average of specific columns or rows (with some conditions). Let's take a look at the following example:
SELECT AVG(population) FROM country WHERE population < 4478500;
Task
Write an SQL query to retrieve the average value of a surfacearea
column from the country table.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |
Thanks for your feedback!
AVG()
returns the average value of a certain column.
Let's see an example:
SELECT AVG(population) FROM country;
AVG()
can also determine the average of specific columns or rows (with some conditions). Let's take a look at the following example:
SELECT AVG(population) FROM country WHERE population < 4478500;
Task
Write an SQL query to retrieve the average value of a surfacearea
column from the country table.
Here's a short example of the country
table:
id | name | continent | region | surfacearea | capital | population |
1 | Japan | Asia | Eastern Asia | 377829 | Tokyo | 126714000 |
2 | Latvia | Europe | NULL | 64589 | Riga | 2424200 |
3 | Mexico | North America | Central America | 1958201 | Mexico City | 98881000 |
... | ... | ... | ... | ... | ... | ... |
15 | Malta | Europe | Southern Europe | 316 | Valletta | 380200 |