We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- SQL
- Aggregation
- Average Population
- Discussions
Average Population
Average Population
Sort by
recency
|
641 Discussions
|
Please Login in order to post a comment
-- MySQL Solution ( Using ROUND() functin )
select round(avg(population)) from CITY;
SELECT ROUND(AVG(POPULATION)) FROM CITY;
SELECT FLOOR(AVG(population)) AS AveragePopulation FROM city;
FLOOR: "Always rounds down!!" to the nearest whole number, which aligns with the requirement to round down. example: 1234.567 becomes 1234 because it’s the integer part of the number, ignoring the decimal portion.
ROUND: Rounds to the nearest integer based on standard rounding rules (0.5 and above rounds up, below 0.5 rounds down), which does not specifically ensure rounding down. example: 1234.567 becomes 1235 because it’s closer to 1235.
SELECT ROUND(AVG(POPULATION)) FROM CITY;