❓ Question https://www.hackerrank.com/challenges/weather-observation-station-14 Weather Observation Station 14 | HackerRank Query the greatest value of the Northern Latitudes from STATION that are under 137.2345 and truncated to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(MAX(lat_n),4) FROM station WHERE lat_n < 137.2345; 📌 Discussion WHERE 절에서 조건을 주고 MAX값을 추출 후 ROUND로 반올림
❓ Question https://www.hackerrank.com/challenges/weather-observation-station-13 Weather Observation Station 13 | HackerRank Query the sum of Northern Latitudes having values greater than 38.7880 and less than 137.2345, truncated to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(SUM(lat_n),4) FROM station WHERE lat_n BETWEEN 38.7880 AND 137.2345; 📌 Discussion WHERE 절에서 BETWEEN으로 범위 조건..
❓ Question https://www.hackerrank.com/challenges/weather-observation-station-2 Weather Observation Station 2 | HackerRank Write a query to print the sum of LAT_N and the sum of LONG_W separated by space, rounded to 2 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(SUM(lat_n),2), ROUND(SUM(long_w),2) FROM station; 📌 Discussion 모든 lat_n과 long_w를 각각 합친 후 ROUND로 반올림하여 소수점 둘째자리까지 표현한다.
❓ Question https://www.hackerrank.com/challenges/earnings-of-employees Top Earners | HackerRank Find the maximum amount of money earned by any employee, as well as the number of top earners (people who have earned this amount). www.hackerrank.com ❗ Answer SELECT months*salary, COUNT(*) FROM employee WHERE months*salary = (SELECT max(months*salary) FROM employee) GROUP BY months*salary; 📌 Discuss..
❓ Question https://www.hackerrank.com/challenges/revising-aggregations-the-count-function Revising Aggregations - The Count Function | HackerRank Query the number of cities having populations larger than 100000. www.hackerrank.com ❗ Answer SELECT COUNT(name) FROM city WHERE population > 100000; 📌 Discussion where에서 조건문을 걸어주고 count로 집계
❓ Question https://www.hackerrank.com/challenges/the-blunder The Blunder | HackerRank Query the amount of error in Sam's result, rounded up to the next integer. www.hackerrank.com ❗ Answer SELECT ROUND(AVG(salary))-ROUND(AVG(replace(salary,'0',''))) FROM employees; 📌 Discussion replace로 salary column의 string data의 '0'을 ''으로 변경 AVG는 숫자로 구성된 문자열도 집계 가능 개별 평균값을 반올림한 값의 차이를 계산해줌
❓ Question https://www.hackerrank.com/challenges/population-density-difference Population Density Difference | HackerRank Query the difference between the maximum and minimum city populations in CITY. www.hackerrank.com ❗ Answer SELECT MAX(population) - MIN(population) FROM city; 📌 Discussion max - min으로 최댓값 - 최솟값 추출
❓ Question https://www.hackerrank.com/challenges/japan-population Japan Population | HackerRank Query to the sum of the populations of all Japanese cities in CITY. www.hackerrank.com ❗ Answer SELECT SUM(population) FROM city WHERE countrycode = 'JPN'; 📌 Discussion where 절에서 조건에 맞는 레코드만 추출 후 sum 집계