-
보호소에서 중성화한 동물SQL/SQL 연습문제 풀이 2022. 1. 19. 13:53반응형
https://programmers.co.kr/learn/courses/30/lessons/59045
MySQL, Oracle
SELECT A.ANIMAL_ID, A.ANIMAL_TYPE, A.NAME FROM ANIMAL_INS A JOIN ANIMAL_OUTS B ON A.ANIMAL_ID = B.ANIMAL_ID WHERE SEX_UPON_INTAKE <> SEX_UPON_OUTCOME ORDER BY A.ANIMAL_ID
SELECT A.ANIMAL_ID, A.ANIMAL_TYPE, A.NAME FROM ( SELECT ANIMAL_ID, ANIMAL_TYPE, NAME FROM ANIMAL_INS WHERE SEX_UPON_INTAKE like 'Intact%' ) A JOIN ( SELECT ANIMAL_ID, ANIMAL_TYPE, NAME FROM ANIMAL_OUTS WHERE SEX_UPON_OUTCOME like 'Spayed%' OR SEX_UPON_OUTCOME like 'Neutered%' ) B ON A.ANIMAL_ID = B.ANIMAL_ID ORDER BY A.ANIMAL_ID
반응형