본문 바로가기

Algorithm/SQL

(42)
(SQL) - LeetCode (easy) 620. Not Boring Movies https://leetcode.com/problems/not-boring-movies/description/ Not Boring Movies - LeetCode Can you solve this real interview question? Not Boring Movies - Table: Cinema +----------------+----------+ | Column Name | Type | +----------------+----------+ | id | int | | movie | varchar | | description | varchar | | rating | float | +---------------- leetcode.com where 조건과 order by를 사용해본 문제였습니다. 📕 풀이방..
(SQL) - LeetCode (easy) 607. Sales Person https://leetcode.com/problems/sales-person/description/ Sales Person - LeetCode Can you solve this real interview question? Sales Person - Table: SalesPerson +-----------------+---------+ | Column Name | Type | +-----------------+---------+ | sales_id | int | | name | varchar | | salary | int | | commission_rate | int | | hire_date | leetcode.com 조건절과 in을 사용해본 문제였습니다. 📕 풀이방법 📔 풀이과정 1. order과 com..
(SQL) - LeetCode (easy) 596. Classes More Than 5 Students https://leetcode.com/problems/classes-more-than-5-students/description/ Classes More Than 5 Students - LeetCode Can you solve this real interview question? Classes More Than 5 Students - Table: Courses +-------------+---------+ | Column Name | Type | +-------------+---------+ | student | varchar | | class | varchar | +-------------+---------+ (student, class) is the leetcode.com group by ~ havin..
(SQL) - LeetCode (easy) 586. Customer Placing the Largest Number of Orders https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/description/ Customer Placing the Largest Number of Orders - LeetCode Can you solve this real interview question? Customer Placing the Largest Number of Orders - Table: Orders +-----------------+----------+ | Column Name | Type | +-----------------+----------+ | order_number | int | | customer_number | int | +-----------..
(MySQL) - LeetCode (easy) 197. Rising Temperature https://leetcode.com/problems/rising-temperature/description/ Rising Temperature - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com left outer join을 사용해 푼 문제였습빈다. 📕 풀이방법 📔 풀이과정 join을 자기 자신 table인 Weather로 하되, 바로 다음날의 date row와 합니다. 이는 datediff함수로 구할 수 있습니다.datediff(종료일, 시작일) = 1인 경우..
(MySQL) - LeetCode (easy) 196. Delete Duplicate Emails https://leetcode.com/problems/delete-duplicate-emails/description/ Delete Duplicate Emails - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com delete문을 사용해보는 문제였습니다. 📕 풀이방법 📔 풀이과정 자기 자신 table에 대해 left outer join을 사용해 email은 중복이며 id는 더 큰 row들을 찾아 지워줍니다. 📕 Code 📔 MySQL delete a from Pe..
(MYSQL) - 프로그래머스 (Summer/Winter Coding(2019)) : 우유와 요거트가 담긴 장바구니 https://programmers.co.kr/learn/courses/30/lessons/62284 코딩테스트 연습 - 우유와 요거트가 담긴 장바구니 CART_PRODUCTS 테이블은 장바구니에 담긴 상품 정보를 담은 테이블입니다. CART_PRODUCTS 테이블의 구조는 다음과 같으며, ID, CART_ID, NAME, PRICE는 각각 테이블의 아이디, 장바구니의 아이디, 상품 종류, 가 programmers.co.kr left outer join, group by를 사용하는 문제였습니다. 풀이방법 1. 같은 테이블을 left outer join합니다 2. outer table의 name이 'Yogurt'고 inner table의 name이 'Milk'인 경우거나 outer table의 name이 ..
(MYSQL) - 프로그래머스(2021 Dev-Matching: 웹 백엔드 개발자) : 헤비 유저가 소유한 장소 programmers.co.kr/learn/courses/30/lessons/77487 코딩테스트 연습 - 헤비 유저가 소유한 장소 PLACES 테이블은 공간 임대 서비스에 등록된 공간의 정보를 담은 테이블입니다. PLACES 테이블의 구조는 다음과 같으며 ID, NAME, HOST_ID는 각각 공간의 아이디, 이름, 공간을 소유한 유저의 아이디를 programmers.co.kr nested query를 사용하는 문제였습니다. 풀이방법 HOST_ID의 row 개수가 1초과인 열들을 뽑은 후 모든 열에서 HOST_ID와 매칭되는 열을 출력했습니다. Code SELECT ID, NAME, HOST_ID FROM PLACES WHERE HOST_ID IN ( SELECT HOST_ID FROM PLACES G..