본문 바로가기

코딩테스트

(50)
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..
184. Department Highest Salary 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 columns) of the ID from the Department table. Each row of this table indicates the ID, name, and sa..
SQL 고득점 kit(GROUP BY) - 저자 별 카테고리 별 매출액 집계하기 -- 풀이 -- '2022년 1월', '저자 별 카테고리 별 매출액', '저자 ID 오름차순, 카테고리 내림차순' SELECT B.AUTHOR_ID , A.AUTHOR_NAME , B.CATEGORY , SUM(B.PRICE*BS.SALES) AS TOTAL_SALES FROM BOOK_SALES BS LEFT JOIN BOOK B ON BS.BOOK_ID = B.BOOK_ID LEFT JOIN AUTHOR A ON B.AUTHOR_ID = A.AUTHOR_ID WHERE YEAR(BS.SALES_DATE) = '2022' AND MONTH(BS.SALES_DATE) = '1' GROUP BY A.AUTHOR_NAME, B.CATEGORY ORDER BY A.AUTHOR_ID, B.CATEGORY DES..