집순이 놀이터

[프로그래머스] 입양 시각 구하기(2) 본문

Study/SQL

[프로그래머스] 입양 시각 구하기(2)

방구석집순이 2022. 6. 16. 07:25

https://programmers.co.kr/learn/courses/30/lessons/59413

 

코딩테스트 연습 - 입양 시각 구하기(2)

ANIMAL_OUTS 테이블은 동물 보호소에서 입양 보낸 동물의 정보를 담은 테이블입니다. ANIMAL_OUTS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, NAME, SEX_UPON_OUTCOME는 각각 동물의 아이디, 생물

programmers.co.kr

 

프로그래머스의 문제가 전반적으로 쉬운 편이었는데, 딱 한 문제가 너무 어려웠다. 

MySQL 기준으로 풀다보니, level 의 개념을 표현하는데서 어려움을 겪었다. 

검색해 보니, 두 가지 풀이 방법이 존재했다. 

 

 

1. With Recursive 

출처 

: https://dev.mysql.com/doc/refman/8.0/en/with.html#common-table-expressions-recursive

 

MySQL :: MySQL 8.0 Reference Manual :: 13.2.15 WITH (Common Table Expressions)

13.2.15 WITH (Common Table Expressions) A common table expression (CTE) is a named temporary result set that exists within the scope of a single statement and that can be referred to later within that statement, possibly multiple times. The following disc

dev.mysql.com

https://huilife.tistory.com/42 

 

[WITH RECURSIVE] 프로그래머스 - 입양 시각 구하기(2)

프로그래머스 문제를 풀다가.. 띠용 했다. https://programmers.co.kr/learn/courses/30/lessons/59413 코딩테스트 연습 - 입양 시각 구하기(2) ANIMAL_OUTS 테이블은 동물 보호소에서 입양 보낸 동물의 정보를 담..

huilife.tistory.com

 

 

2. Set 을 이용한 변수 선언 

https://jaaamj.tistory.com/155?category=906318 

 

[프로그래머스 SQL] 입양 시각 구하기(2)

문제 설명 ANIMAL_OUTS 테이블은 동물 보호소에서 입양 보낸 동물의 정보를 담은 테이블입니다. ANIMAL_OUTS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, NAME, SEX_UPON_OUTCOME는..

jaaamj.tistory.com

 

'Study > SQL' 카테고리의 다른 글

[Partition By]  (0) 2022.06.21
[SQL] With ( Common Table Expression)(작성중)  (0) 2022.06.17
[SQL zoo] Self Join 10  (0) 2022.06.16
[SQL] 문제풀이 사이트 목록  (0) 2022.06.16
CSV 파일 MySql 테이블에 업로드 하기  (0) 2022.06.15