-
[프로그래머스] 보호소에서 중성화한 동물 MYSQLCoding Test/programmers 2023. 1. 6. 13:57728x90
문제 설명
보호소에서 중성화 수술을 거친 동물 정보를 알아보려 합니다. 보호소에 들어올 당시에는 중성화1되지 않았지만, 보호소를 나갈 당시에는 중성화된 동물의 아이디와 생물 종, 이름을 조회하는 아이디 순으로 조회하는 SQL 문을 작성해주세요.
풀이
SELECT I.ANIMAL_ID, I.ANIMAL_TYPE, I.NAME FROM ANIMAL_INS I LEFT JOIN ANIMAL_OUTS O ON I.ANIMAL_ID = O.ANIMAL_ID WHERE I.SEX_UPON_INTAKE != O.SEX_UPON_OUTCOME ORDER BY I.ANIMAL_ID;
다른 풀이
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 A.SEX_UPON_INTAKE LIKE 'INTACT%' AND (B.SEX_UPON_OUTCOME LIKE 'SPAYED%' OR B.SEX_UPON_OUTCOME LIKE 'NEUTERED%') ORDER BY A.ANIMAL_ID
728x90'Coding Test > programmers' 카테고리의 다른 글
[프로그래머스] 점 찍기 c++ (0) 2023.01.06 [프로그래머스] 디펜스 게임 c++ (0) 2023.01.06 [프로그래머스] 그룹별 조건에 맞는 식당 목록 출력하기 MYSQL (0) 2023.01.06 [프로그래머스] 5월 식품들의 총매출 조회하기 MYSQL (0) 2023.01.06 [프로그래머스] 주문량이 많은 아이스크림들 조회하기 MYSQL (0) 2023.01.06