목록HackerRank (12)
Allen's 데이터 맛집

문제 풀이 select round(abs(min(lat_n) - max(LAT_N)) + abs(min(LONG_W) - max(LONG_W)),4) from station 1. MIN() 및 MAX() 함수를 사용하여 위도(LAT_N)와 경도(LONG_W)의 최소값과 최대값을 구합니다. 2. 각 축에 대한 거리는 절댓값(abs)을 사용하여 계산됩니다. 위도(LAT_N)의 경우, 최대값과 최소값의 차이를 구하고, 경도(LONG_W)의 경우에도 최대값과 최소값의 차이를 구합니다. 3. 이러한 두 축에 대한 거리를 합산하여 총 거리를 계산합니다. 4. ROUND() 함수를 사용하여 결과를 소수점 이하 4자리까지 반올림합니다. https://www.hackerrank.com/challenges/weather-..

문제 풀이 select c.company_code ,c.founder ,count(distinct lm.lead_manager_code) ,count(distinct sm.senior_manager_code) ,count(distinct m.manager_code) ,count(distinct e.employee_code) from company c join lead_manager lm on c.company_code = lm.company_code join senior_manager sm on sm.company_code = lm.company_code join manager m on sm.company_code = m.company_code join employee e on m.company_code..

문제 풀이 select N, case when P is NULL then "Root" when N in (select P from bst) then "Inner" else "Leaf" end from bst order by N 해당 문제는 이진 탐색 트리(BST)의 각 노드에 대해 해당 노드의 유형을 결정하는 것입니다. 1. 각 노드의 이름(N)을 선택합니다. 2. CASE 문을 사용하여 각 노드의 유형을 확인합니다. - P 값이 NULL인 경우: 이는 루트 노드를 나타냅니다. 따라서 "Root"로 표시됩니다. - P 값이 NULL이 아니고, 해당 노드의 이름(N)이 다른 노드의 부모 노드로 지정된 경우: 이는 내부 노드를 나타냅니다. 따라서 "Inner"로 표시됩니다. - 그렇지 않은 경우: 이는 리프..

문제 풀이 select concat(name, '(', SUBSTRING(OCCUPATION, 1, 1), ')') from OCCUPATIONS order by name; select concat('There are a total of ', count(OCCUPATION),' ', LOWER(OCCUPATION),'s.') from OCCUPATIONS group by OCCUPATION order by count(OCCUPATION); 1. 첫 번째 쿼리는 직업(OCCUPATIONS) 테이블에서 각 직업의 이름을 그 직업의 첫 글자와 함께 출력합니다. 이를 위해 CONCAT() 함수를 사용하여 이름과 직업의 첫 글자를 결합하고, SUBSTRING() 함수를 사용하여 직업의 첫 글자를 추출합니다. 그런..