본문 바로가기

언어 & 라이브러리30

해커랭크 HackerRank Binary Tree Nodes Advanced Select 문제 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 Output 1 Leaf 2 Inner 3 Leaf 5 Root 6 Leaf 8 Inner 9 Leaf 문제 풀이 노드 상태에 따라 출력되는 값이 달라져야 하기 때문에 case문을 적용 시킨다. order by로 N의 오름차순에 따라 값을 정렬하고 nodeType을 결정하는 것은 부.. 2022. 1. 19.
해커랭크 HackerRank The PADS Advanced Select The PADS 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). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format: where [occupation_count] is the number of occurrences of an occ.. 2022. 1. 19.
SQLZOO SELECT BASIC 문제 풀이 2. name,population을 보여주고 Sweden,Norway,Denmark를 선택한다. SELECT name, population FROM world WHERE name IN ('Sweden', 'Norway', 'Denmark'); 3. 200000과 250000 area를 구하라 SELECT name, area FROM world WHERE area BETWEEN 200000 AND 250000 4. Show the name and population in millions for the countries of the continent 'South America'. Divide the population by 1000000 to get population in millions. select n.. 2022. 1. 19.
해커랭크 HackerRank The Report Basic Join The Report Students 테이블은 ID, NAME, MARKS / Grades 테이블은 Grade, Min_Mark, Max_Mark가 있다. Students의 Marks를 통해 Grade 테이블의 점수 범위대로 Grade를 구해야 한다. 또한 Grade가 8 미만인 학생은 이름이 아닌 NULL을 출력해야 한다. 정렬은 1. Grade 내림차순, 2. 이름 오름차순이다. SELECT IF(GRADE < 8, NULL, NAME), GRADE, MARKS FROM STUDENTS JOIN GRADES WHERE MARKS BETWEEN MIN_MARK AND MAX_MARK ORDER BY GRADE DESC, NAME 2022. 1. 19.
해커랭크 HackerRank Type of Triangle Advanced Select Type of Triangle - CASE END를 활용해야 합니다. Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Equilateral: It's a triangle with 3 sides of equal length. Isosceles: It's a triangle with 2 sides of equal length. Scalene: It's a triangle with 3 sides of differing lengths. Not A Triangle: The given values of A, B, and C don't form a triangle SELECT CAS.. 2022. 1. 19.
해커랭크 Hackerrank SQL BASIC Select 문제풀이 MYSQL 기준 풀이입니다.!! Revising the Select Query I - City 테이블에서 countrycode가 USA이며 population이 100000 초과인 컬럼을 호출하라는 문제입니다. SELECT * FROM CITY WHERE countrycode = "USA" AND population > 100000; Revising the Select Query 2 - 같은 맥락의 문제로 생략하겠습니다. Select By ID - id가 1661인 컬럼을 찾으라는 문제입니다. SELECT * FROM CITY WHERE id=1661 Weather Observation Station 4 - 전체 city의 개수와 중복이 제거된 city의 개수를 빼라는 문제입니다. SELECT COUNT.. 2022. 1. 19.