-
[프로그래머스] 진료과별 총 예약 횟수 출력하기 MYSQLCoding Test/programmers 2023. 1. 7. 00:56728x90
문제 설명
APPOINTMENT 테이블에서 2022년 5월에 예약한 환자 수를 진료과코드 별로 조회하는 SQL문을 작성해주세요. 이때, 컬럼명은 '진료과 코드', '5월예약건수'로 지정해주시고 결과는 진료과별 예약한 환자 수를 기준으로 오름차순 정렬하고, 예약한 환자 수가 같다면 진료과 코드를 기준으로 오름차순 정렬해주세요.
풀이
SELECT MCDP_CD AS '진료과코드', COUNT(MCDP_CD) AS '5월예약건수' FROM APPOINTMENT WHERE APNT_YMD LIKE '2022-05%' GROUP BY MCDP_CD ORDER BY COUNT(MCDP_CD) ASC, MCDP_CD ASC
728x90'Coding Test > programmers' 카테고리의 다른 글
[프로그래머스] 동명 동물 수 찾기 MYSQL (0) 2023.01.07 [프로그래머스] 입양 시각 구하기(1) MYSQL (0) 2023.01.07 [프로그래머스] 성분으로 구분한 아이스크림 총 주문량 MYSQL (0) 2023.01.07 [프로그래머스] 우박수열 정적분 c++ (0) 2023.01.07 [프로그래머스] 점 찍기 c++ (0) 2023.01.06