inblog logo
|
sxias
    Programmers_SQLSELECT

    [Programmers_SQL] 8. 12세 이하인 여자 환자 목록 출력하기

    문정준's avatar
    문정준
    Feb 28, 2025
    [Programmers_SQL] 8. 12세 이하인 여자 환자 목록 출력하기
    Contents
    1. 문제 설명2. 문제3. 예시4. 문제 풀이5. 결과 확인
    💡
    프로그래머스 SELECT 8. 12세 이하인 여자 환자 목록 출력하기

    1. 문제 설명

    notion image
     

    2. 문제

    notion image

    3. 예시

    notion image

    4. 문제 풀이

    SELECT pt_name, pt_no, gend_cd, age, ifnull(tlno, 'NONE') tlno from PATIENT where age <= 12 and gend_cd = 'W' order by age desc, pt_name asc;
    • 1 Line : 환자이름, 환자번호, 성별코드, 나이, 전화번호를 출력
      • 전화번호가 없는 경우 ‘NONE’으로 출력
      • SELECT pt_name, pt_no, gend_cd, age, ifnull(tlno, ‘NONE’) tlno
    • 2 Line : PATIENT 테이블에서 출력
      • FROM PATIENT
    • 3 Line : 12세 이하인 여자 환자만을 출력
      • where age ≤ 12 and gend_cd = ‘W’
    • 4 Line : 나이를 기준으로 내림차순, 환자이름을 기준으로 오름차순 정렬
      • order by age desc, pt_name asc;

    5. 결과 확인

    notion image
    notion image
     
    Share article
    Contents
    1. 문제 설명2. 문제3. 예시4. 문제 풀이5. 결과 확인

    Sxias ㆍ a32176740@gmail.com

    RSS·Powered by Inblog