본문 바로가기

분류 전체보기40

[LeetCode] - 1158. Market Analysis 1 문제 Write a solution to find for each user, the join date and the number of orders they made as a buyer in 2019. Return the result table in any order. " 2019년 구매자로서 사용자별로 가입일, 주문한 수량을 작성하시오.: 문제 풀이 SELECT u.user_id AS buyer_id , u.join_date , IFNULL(COUNT(o.order_date),0) AS orders_in_2019 FROM Users AS u LEFT JOIN Orders AS o ON o.buyer_id = u.user_id AND YEAR(order_date) = '2019' 주의해야 할점 1) WHE.. 2024. 4. 15.
[LeetCode] - 1070.Product Sales Analysis 3 문제 Write a solution to select the product id, year, quantity, and pricefor the first year of every product sold. Return the resulting table in any order. The result format is in the following example. "판매되는 모든 제품의 첫 해 제품 id, 연도, 수량, 가격을 선택할 수 있는 솔루션을 작성하시오." 풀이 과정 SELECT product_id, year AS first_year, quantity, price FROM sales WHERE (product_id,year) IN (SELECT product_id,min(year) AS year FRO.. 2024. 4. 15.
[LeetCode] 1084. Sales Analysis 3 문제 Write a solution to report the products that were only sold in the first quarter of 2019. That is, between 2019-01-01 and 2019-03-31 inclusive. Return the result table in any order. "2019년 1분기에만 판매된 제품을 알 수 있는 쿼리를 작성해라 즉, 2019-01-01 부터 2019-03-01 사이에 포함된다." 문제 풀이 product_id 별로 날짜를 확인 해야 한다. 이때 중요하건 product_id 모두가 1분기 날짜에 팔려야 한다. 즉, 1개라도 1분기 날자 이후에 판매된 경우는 제외되어야 한다. SELECT s.product_id , p.pro.. 2024. 4. 10.
[LeetCode] - 608. Tree Node 문제 Each node in the tree can be one of three types: "Leaf": if the node is a leaf node."Root": if the node is the root of the tree."Inner": If the node is neither a leaf node nor a root node. Write a solution to report the type of each node in the tree. Return the result table in any order. " Leef, Root, Inner로 분류하여라" 문제 풀이 1) Root의 경우는 p_id가 Null 인 경우이다. 2) Inner의 경우는 P-id가 id에 속해 있어야 하고, id도 역.. 2024. 4. 10.