SQL | HackerRank 평균 오차 구하기 (Replace)
·
Computer Science/SQL
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary.Write a query calculating the amount of error (i.e.: avera..
SQL | HackerRank 이진 트리 노드 유형(Root, Inner, Leaf) 구분하는 쿼리
·
Computer Science/SQL
You are given a table, BST, containing two columns: N and P, where Nrepresents the value of a node in Binary Tree, and P is the parent of N.Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node:Root: If node is root node.Leaf: If node is leaf node.Inner: If node is neither root nor leaf node.Sample Input ExplanationThe Bina..
SQL | HackerRank MAX(CASE WHEN…)을 활용한 피벗(Pivot) 쿼리
·
Computer Science/SQL
Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output should consist of four columns (Doctor, Professor, Singer, and Actor) in that specific order, with their respective names listed alphabetically under each column.Note: Print NULL when there are no more names corresponding to an occupation.Input F..
SQL | HackerRank 문자열을 이어붙이기 (CONCAT)
·
Computer Science/SQL
Generate the following two result sets:Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascendi..
SQL | HackerRank 정규표현식으로 도시 찾기 – DISTINCT와 REGEXP 활용
·
Computer Science/SQL
Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.Input FormatThe 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 city REGEXP '^[aeiouAEIOU]';SELECT DISTINCT CITY: 중복된 도시 이름 제거.WHERE CITY REGEXP '^[aeiouAEIOU]': 도시 이름이..
SQL | HackerRank 가장 짧고 긴 도시 이름 찾기 – 문자열 길이 기반 SQL 정렬과 조건 추출
·
Computer Science/SQL
Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. The STATION table is described as follows:where LAT_N is the northern latitude and LONG_W is the western longitude.ExplanationWhen or..
올리브한입