HackerRank-My SQL

Prepare > SQL > Aggregation > Average Population

stem_sw 2023. 5. 16. 20:32
 

Average Population | HackerRank

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

www.hackerrank.com

 

문제


Query the average population for all cities in CITY, rounded down to the nearest integer.

 

 

 

 

코드


SELECT FLOOR(AVG(POPULATION)) FROM CITY;
  • 반올림이랑 내림이랑 다른데...어찌어찌 정답처리가 됐네

 

 

두 번째 시도

SELECT ROUND(AVG(POPULATION),0) FROM CITY;