기존학습자료/leetcode, hackerrank
해커랭크 - 올림/내림/반올림, 절대값/제곱/제곱근
gooreumsea
2023. 6. 25. 05:18
* CEIL - 소수점 첫째 자리에서 올림
* FLOOR - 소수점 첫째 자리에서 내림
* ROUND - 숫자를 각 자리에서 반올림
* TRUNCATE(숫자, 버릴 자릿수) - 숫자를 버릴 자릿수 아래로 버림
* ABS - 절대값
* POWER - 제곱
* SQRT - 양수 x 에 대한 제곱근을 반환
Average Population
https://www.hackerrank.com/challenges/average-population/problem
SELECT Floor(AVG(population))
FROM CITY
Weather Observation Station 2
https://www.hackerrank.com/challenges/weather-observation-station-2/submissions/database/293205884
SELECT ROUND(SUM(LAT_N),2) AS lat
,ROUND(SUM(LONG_W),2) AS lon
FROM STATION
Weather Observation Station 18 - Medium
https://www.hackerrank.com/challenges/weather-observation-station-18/problem
SELECT ROUND(ABS(MIN(LAT_N)-MAX(LAT_N)) + ABS(MIN(LONG_W)-MAX(LONG_W)),4)
FROM STATION
Weather Observation Station 19 - Medium
https://www.hackerrank.com/challenges/weather-observation-station-19/problem
SELECT TRUNCATE(SQRT( POWER(MAX(LAT_N)-MIN(LAT_N),2) + POWER(MAX(LONG_W)-MIN(LONG_W),2) ),4)
FROM STATION
Average Population of Each Continent
https://www.hackerrank.com/challenges/average-population-of-each-continent/problem
SELECT COUNTRY.CONTINENT, FLOOR(AVG(city.population)) FROM CITY
INNER JOIN COUNTRY ON COUNTRY.Code = CITY.CountryCode
GROUP BY COUNTRY.CONTINENT