❗ 풀이 과정
- 취소되지 않은 흉부외과 (CS) 진료 예약 내역 조회
(APNT_NO, PT_NAME, PT_NO, MCDP_CD, DR_NAME, APNT_YMD)
- Join Key
PATIENT
,APPOINTMENT
: PT_NO
환자번호
DOCTOR
,APPOINTMENT
: MCDP_CD
진료과코드
DOCTOR
,APPOINTMENT
: (MD)DR_ID
의사ID
🤜 풀이 코드
SELECT A.APNT_NO, P.PT_NAME, P.PT_NO, A.MCDP_CD, D.DR_NAME, A.APNT_YMD
FROM APPOINTMENT A, PATIENT P, DOCTOR D
WHERE A.APNT_CNCL_YN ='N'
AND A.MCDP_CD = 'CS'
AND P.PT_NO = A.PT_NO
AND D.MCDP_CD = A.MCDP_CD
AND A.MDDR_ID = D.DR_ID
AND TO_CHAR(A.APNT_YMD,'YYYY-MM-DD')='2022-04-13'
ORDER BY A.APNT_YMD;