PatientID
FirstName
LastName
DateOfBirth
1
11
Kyle
Lopez
1983-08-20
2
53
Anna
Chapman
1988-06-10
3
66
Oscar
Jenkins
1996-12-12
4
88
Kim
Chapman
1981-05-15
5
111
Holly
Rivera
1985-01-15
6
141
Leo
Nelson
1983-08-20
7
147
Ruth
Harris
1990-01-02
8
159
David
Richardson
1986-04-14
9
162
Giselle
Hall
1989-03-30
10
195
Noah
Lewis
1984-05-30
11
196
Olivia
Clark
1995-07-19
12
197
Parker
Hall
1980-02-28
Picture 4.1
Question 5:
Write a query to display DoctorID, FirstName, LastName, DepartmentName,NumberOfAppointments corresponding to each doctor of two departments named 'Pediatrics' and 'General Surgery'; where NumberOfAppointments is the number of 'Completed' appointments in 2023 of each doctor. Order the results in descending order of NumberOfAppointments, then in ascending order of DoctorID for rows having the same NumberOfAppointments as in the following figure. Note that all doctors of these two departments must be displayed.
DoctorID
FirstName
LastName
DepartmentName
NumberOfAppointments
1
1
John
Doe
Pediatrics
2
2
8
Robert
Martinez
General Surgery 2
3
29
Melissa
Young
Pediatrics
2
4
40
Samuel
Carter
Pediatrics
2
5
48
Keith
Evans
General Surgery 2
6 50
Frank
Collins
Pediatrics
2
7
11
Jennifer
Wilson
Pediatrics
1
8 20
Helen
Thompson
General Surgery 1
Zoom
+ 91%
Close