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.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Average Population
You are viewing a single comment's thread. Return to all comments →
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.