SQL 문제풀이

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 19

❓ Question https://www.hackerrank.com/challenges/weather-observation-station-19 Weather Observation Station 19 | HackerRank Query the Euclidean Distance between two points and round to 4 decimal digits. www.hackerrank.com ❗ Answer SELECT ROUND(POW(POW(MAX(lat_n)-MIN(lat_n),2) + POW(MAX(long_w)-MIN(long_w),2),0.5),4) FROM station; 📌 Discussion 유클리디안 거리는 x축 거리 제곱과 y축 거리 제곱의 합의 제곱근이다. POW로 제곱과 제곱근을..

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 18

❓ Question https://www.hackerrank.com/challenges/weather-observation-station-18 Weather Observation Station 18 | HackerRank Query the Manhattan Distance between two points, round or truncate to 4 decimal digits. www.hackerrank.com ❗ Answer SELECT ROUND((MAX(lat_n)-MIN(lat_n)+MAX(long_w)-MIN(long_w)),4) FROM station; 📌 Discussion 맨하탄 거리는 x축 거리와 y축 거리의 합이다. 따라서 lat_n과 long_w 각각의 최대값과 최소값의 차이를 더해준다.

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 17

❓ Question https://www.hackerrank.com/challenges/weather-observation-station-17 Weather Observation Station 17 | HackerRank Query the Western Longitude for the smallest value of the Northern Latitudes greater than 38.7780 in STATION and round to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(long_w,4) FROM station WHERE lat_n = (SELECT MIN(lat_n) FROM station WHERE lat_n > 38.7780); ..

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 16

❓ Question https://www.hackerrank.com/challenges/weather-observation-station-16 Weather Observation Station 16 | HackerRank Query the smallest of STATION's Northern Latitudes that is greater than 38.7780, and round to 4 decimal places www.hackerrank.com ❗ Answer SELECT ROUND(MIN(lat_n),4) FROM station WHERE lat_n > 38.7780; 📌 Discussion WHERE 절에서 조건을 걸고 최소값에 반올림하여 레코드 추출

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 15

❓ Question https://www.hackerrank.com/challenges/weather-observation-station-15 Weather Observation Station 15 | HackerRank Query the Western Longitude for the largest Northern Latitude under 137.2345, rounded to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(long_w,4) FROM station WHERE lat_n = (SELECT MAX(lat_n) FROM station WHERE lat_n < 137.2345); 📌 Discussion sub query scalar로 W..

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 14

❓ 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로 반올림

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 13

❓ 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으로 범위 조건..

SQL 문제풀이

[해커랭크 SQL] Aggregation - Weather Observation Station 2

❓ 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로 반올림하여 소수점 둘째자리까지 표현한다.

냄비짱
'SQL 문제풀이' 카테고리의 글 목록