Data Analyst KIM

[프로그래머스_SQL] Lv4_보호소에서 중성화한 동물 본문

데이터 분석/Coding Test

[프로그래머스_SQL] Lv4_보호소에서 중성화한 동물

김두연 2023. 10. 16. 21:53
반응형

<문제 풀이>

1. RIGHT JOIN

2. ai LIKE 'I%' AND ao NOT LKIE 'I%'

 

SELECT ai.ANIMAL_ID
     , ai.ANIMAL_TYPE	
     , ai.NAME
FROM ANIMAL_INS ai
RIGHT JOIN ANIMAL_OUTS ao ON ai.ANIMAL_ID = ao.ANIMAL_ID
WHERE ai.SEX_UPON_INTAKE LIKE 'Intact%' AND ao.SEX_UPON_OUTCOME  NOT LIKE 'Intact%'
SELECT ai.ANIMAL_ID
     , ai.ANIMAL_TYPE	
     , ai.NAME
FROM ANIMAL_INS ai
RIGHT JOIN ANIMAL_OUTS ao ON ai.ANIMAL_ID = ao.ANIMAL_ID
WHERE ai.SEX_UPON_INTAKE LIKE 'Intact%' AND ao.SEX_UPON_OUTCOME  NOT LIKE 'Intact%'
반응형