본문 바로가기

HackerRank3

[Hackerrank] Binary Tree Nodes https://www.hackerrank.com/challenges/binary-search-tree-1/problem?isFullScreen=true Binary Tree Nodes | HackerRank Write a query to find the node type of BST ordered by the value of the node. www.hackerrank.com 1. 재귀 CTE 문 이용하기 WITH RECURSIVE TMP AS( SELECT N, P, 1 AS DEPT FROM BST WHERE P IS null UNION ALL SELECT BST.N, BST.P, TMP.DEPT+1 AS DEPT FROM TMP INNER JOIN BST ON TMP.N = BST.P) SELECT.. 2022. 2. 15.
[Hackerrank] Occupations 문제 https://www.hackerrank.com/challenges/occupations/problem?isFullScreen=true Occupations | HackerRank Pivot the Occupation column so the Name of each person in OCCUPATIONS is displayed underneath their respective Occupation. www.hackerrank.com 아래 데이터를 피벗 형태로 반환하기 Name Occupation Aamina Doctor Ashley Professor Christeen Singer Eve Actor ↓ 결과 Doctor Professor Singer Actor Aamina Ashley Christeen.. 2022. 1. 25.
[HACKERRANK] AVERAGE POPULATION https://www.hackerrank.com/challenges/average-population/problem?isFullScreen=true Average Population | HackerRank Query the average population of all cities, rounded down to the nearest integer. www.hackerrank.com 상당히 쉬운 문젠데 자꾸 비슷한 함수끼리 헷갈려서 정리해본다. 인구 평균을 버림해서 정수로 값을 도출해라. SELECT FLOOR(AVG(POPULATION)) FROM CITY > ROUND (값, 반올림해서 남길 자리 수) - 반올림할 때 사용하는 함수 - 값 뒤에 나오는 숫자는 .. 2022. 1. 24.