본문 바로가기

코딩테스트/SQL - Leetcode

(19)
1158. Market Analysis I Table: Users +----------------+---------+ | Column Name | Type | +----------------+---------+ | user_id | int | | join_date | date | | favorite_brand | varchar | +----------------+---------+ user_id is the primary key (column with unique values) of this table. This table has the info of the users of an online shopping website where users can sell and buy items. Table: Orders +---------------+---..
608. Tree Node Table: Tree +-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | p_id | int | +-------------+------+ id is the column with unique values for this table. Each row of this table contains information about the id of a node and the id of its parent node in a tree. The given structure is always a valid tree. Each node in the tree can be one of three types: "Leaf": if th..
585. Investments in 2016 Table: Insurance +-------------+-------+ | Column Name | Type | +-------------+-------+ | pid | int | | tiv_2015 | float | | tiv_2016 | float | | lat | float | | lon | float | +-------------+-------+ pid is the primary key (column with unique values) for this table. Each row of this table contains information about one policy where: pid is the policyholder's policy ID. tiv_2015 is the total inve..
Leetcode SQL Easy난이도 전부 해결! 냉무... 는 좀 심심하니까. 24.01.10 Leetcode의 SQL 문제 중 EASY 난이도를 전부 풀었다. 아 물론 무료버전에서 제공되는 문제들만. 무료버전이어도 문제가 꽤나 많다. 한 50여 문제 정도는 되는 듯. 별 건 아니지만, 꾸준히 풀어오기도 했고 이제 Medium으로 넘어가기 전에 그냥 기록이나 남겨 보려고...ㅎ 그리고 Leetsync로 github에 연동되게 설정해 두어서, 아마 다 올라가 있긴 할 것이다.
1789. Primary Department for Each Employee Table: Employee +---------------+---------+ | Column Name | Type | +---------------+---------+ | employee_id | int | | department_id | int | | primary_flag | varchar | +---------------+---------+ (employee_id, department_id) is the primary key (combination of columns with unique values) for this table. employee_id is the id of the employee. department_id is the id of the department to which the ..
1484. Group Sold Products By The Date Table Activities: +-------------+---------+ | Column Name | Type | +-------------+---------+ | sell_date | date | | product | varchar | +-------------+---------+ There is no primary key (column with unique values) for this table. It may contain duplicates. Each row of this table contains the product name and the date it was sold in a market. Write a solution to find for each date the number of d..
178. Rank Scores Table: Scores +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | score | decimal | +-------------+---------+ id is the primary key (column with unique values) for this table. Each row of this table contains the score of a game. Score is a floating point value with two decimal places. Write a solution to find the rank of the scores. The ranking should be cal..
185. Department Top Three Salaries Table: Employee +--------------+---------+ | Column Name | Type | +--------------+---------+ | id | int | | name | varchar | | salary | int | | departmentId | int | +--------------+---------+ id is the primary key (column with unique values) for this table. departmentId is a foreign key (reference column) of the ID from the Department table. Each row of this table indicates the ID, name, and sal..