inblog logo
|
sxias
    Programmers_SQLSELECT

    [Programmers_SQL] 21. 조건에 맞는 회원수 구하기

    문정준's avatar
    문정준
    Mar 14, 2025
    [Programmers_SQL] 21. 조건에 맞는 회원수 구하기
    Contents
    1. 문제 설명2. 문제3. 예시4. 문제 풀이5. 결과 확인
     
    💡
    프로그래머스 SELECT 20. 조건에 맞는 회원수 구하기

    1. 문제 설명

    notion image
     
     

    2. 문제

    notion image

    3. 예시

    notion image

    4. 문제 풀이

    SELECT count(*) USERS from USER_INFO where year(joined) = 2021 and age between 20 and 29;
    • 1 Line : 조건에 맞는 인원 수를 구해야 하므로 count(*) 사용, USERS 별칭 부여
      • SELECT count(*) USERS
    • 2 Line : USER_INFO 테이블에서 조회
      • from USER_INFO
    • 3 Line : 2021년에 가입한 회원 중 나이가 20세 이상, 29세 이하인 회원만 출력
      • Joined = date → year(joined) = 2021
        • where year(joined) = 2021 and age between 20 and 29;

    5. 결과 확인

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

    Sxias ㆍ a32176740@gmail.com

    RSS·Powered by Inblog