Wednesday 28 October 2015

Average function

Given a City table, whose fields are described as

 +-------------+----------
| Field | Type |
+-------------+----------+
| ID | int(11) |
| Name | char(35) |
| CountryCode | char(3) |
| District | char(20) |
| Population | int(11) |
+-------------+----------+

print the average population of all cities, rounded down to the nearest integer.

>>select floor(avg(population)) from city; 

Thanks.

No comments:

Post a Comment