Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Math
- string
- simulation
- bit manipulation
- sorting
- Number Theory
- greedy
- Stack
- Data Structure
- SQL
- java
- Tree
- two pointers
- array
- Counting
- Matrix
- Method
- database
- 코테
- Binary Search
- geometry
- Class
- hash table
- dynamic programming
- 자바
- 파이썬
- 코딩테스트
- implement
- Binary Tree
- 구현
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1050. Actors and Directors Who Cooperated At Least Three Times 본문
코딩테스트 풀이/SQL
[LeetCode/Easy] 1050. Actors and Directors Who Cooperated At Least Three Times
무지맘 2023. 4. 4. 22:581. Input
1) Table: ActorDirector (pk = timestamp)
2. Output
1) 최소 3번 이상 협업한 배우와 감독의 아이디를 출력
- 순서는 상관 없다.
3. Example
4. Code
1) 첫 코드(2023/04/04)
select actor_id, director_id
from (
select actor_id, director_id, count(*) cnt
from ActorDirector
group by actor_id, director_id
) a
where cnt>=3;
- 너무너무 느림
2) having절을 이용해본 코드(2023/04/04)
select actor_id, director_id
from ActorDirector
group by actor_id, director_id
having count(timestamp)>=3;
- 약간 빨라지긴 했으나, 그래도 느린편
- group by와 where를 함께 쓰는 것이 성능에는 도움이 된다고 한다.
'코딩테스트 풀이 > SQL' 카테고리의 다른 글
[LeetCode/Easy] 1148. Article Views I (0) | 2023.04.06 |
---|---|
[LeetCode/Easy] 1068. Product Sales Analysis I (0) | 2023.04.04 |
[LeetCode/Easy] 1075. Project Employees I (0) | 2023.04.04 |
[LeetCode/Easy] 1729. Find Followers Count (0) | 2023.03.29 |
[LeetCode/Easy] 1587. Bank Account Summary II (0) | 2023.03.29 |