728x90

https://school.programmers.co.kr/learn/courses/30/lessons/132202

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

 

풀이)

-- 코드를 입력하세요
SELECT mcdp_cd as "진료과코드", count(distinct apnt_no) as "5월예약건수"
from appointment
where date_format(apnt_ymd, '%Y-%m') = "2022-05"
group by mcdp_cd
order by count(distinct apnt_no),"진료과코드";

이 문제에서 가장 골머리를 앓았던 부분은 order by 절 때문인 것 같다...

order by를 "5월예약건수", "진료과코드"라고 하면 오답이 나온다...

 

 

select mcdp_cd as 진료과코드, count(*) as 5월예약건수
from appointment 
where date_format(apnt_ymd, '%y-%m') like '22-05'
group by mcdp_cd 
order by 5월예약건수 asc, 진료과코드 asc;

그런데,,, 이렇게 하면 또 답이란다

뭔 차이지?ㅠ

728x90

+ Recent posts