목록2025/06 (3)
working_helen

Leetcode 코딩테스트 연습 MySQL Hard✅ 계층형 질의 1) 계층형 데이터 - 동일한 table 내 행끼리 상위/하위 관계가 있는 경우 - 하나의 table에서 특정 행이 다른 행의 상위(부모) 또는 하위(자식) 역할을 하는 데이터 구조- 계층형 데이터는 트리 구조로 설명 가능root node : 최상위 부모 행leaf node : 자식이 없는 최하위 행depth : root node 로부터 특정 노드까지의 거리, root부터 1이며 leaf로 내려갈 때마다 1씩 증가 2) 계층형 질의 Hierarchical Query - 계층형 데이터를 탐색하기 위한 SQL문 - 계층형 데이터를 특정 시작 지점부터 상위/하위 관계를 따라 depth를 탐색하며 쿼리 수행 SELECT 칼럼명FROM 테이블명S..

Leetcode 코딩테스트 연습 MySQL Med. ~ Hard3564. Seasonal Sales Analysis : Find the most popular product category for each season. The popularity of a category is determined by the total quantity sold in that season. If there is a tie, select the category with the highest total revenue (quantity × price). 풀이 : WITH 구문 사용- WITH로 여러 임시 쿼리를 생성할 땐 ' , '로 연결- 앞서 생성한 CTE를 뒤에 생성한 CTE에서 호출 가능 반대는 불가능하므로 CTE 의존..

Leetcode 코딩테스트 연습 MySQL Med.1341. Movie Rating : Find the name of the user who has rated the greatest number of movies. In case of a tie, return the lexicographically smaller user name. Find the movie name with the highest average rating in February 2020. In case of a tie, return the lexicographically smaller movie name. 풀이 : ROWNUM- where절에서 rownum을 사용하기 위해 서브쿼리로 묶기- 절대적인 행 번호가 아닌 가상의 번호이므로 '(..