본문 바로가기

Algorithm/MySQL

(75)
[해커랭크(HackerRank)] Placements (MySQL) 문제 You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID (ID of the ONLY best friend). Packages contains two columns: ID and Salary (offered salary in $ thousands per month). Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be or..
[해커랭크(HackerRank)] Weather Observation Station 3 (MySQL) 문제 Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer. The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the western longitude. 코드 select distinct city from station where id % 2 = 0 -- even Id Number 짝수 아이디만 출력 출력
[해커랭크(HackerRank)] Weather Observation Station 20 (MySQL) 문제 A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to 4 decimal places. Input Format The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the western longitude. 코드 select round(avg(lat_n),4) from (select lat_n, row_number() o..
[해커랭크(HackerRank)] Weather Observation Station 19 (MySQL) 문제 코드 select ROUND(SQRT(POW(MIN(lat_n)-MAX(lat_n),2) + POW(MIN(long_w)-MAX(long_w),2)),4) from station p1(a,c), p2(b,d) a, b = lat_n(위도)의 최소값, 최댓값 = min(lat_n), max(lat_n) c, d = long_w(경도)의 최댓값, 최소값 = min(long_w), max(long_w) 유클리드 거리 = 피타고라스 정의 (a-b)^2 + (c-d)^2 (P1.a - P1.b)^2+ (P2.a - P2.b)^2에서 루트 씌우기 먼저 각각 제곱한 값을 구하기 위해 POW() 함수 씌우기 그 수를 더한 값의 제곱근 구하기 위해 SQRT() 함수 씌우기 소수점 네번째 자리 수까지 반올림하기 위해..