Zoom
viite a query to display, for each depa
all the
lave the highest
of medical records. The results must include DepartmentID, Name, DoctorID,
Kizspy. meorFullName and NumberOfRecords, where DoctorFullName is the concatenation of the
doctor's first name, a whitespace and the doctor's last name. The NumberOfRecords of a
doctor is the total number of medical records associated with that doctor.
DepartmentID Name
DoctorID
DoctorFullName
NumberOfRecords
1
1
Cardiology 35
Rebecca Green
12
2
2
Neurology 14
Jessica Taylor
7
3
2
Neurology 31
Deborah Sanchez 7
4
3
Pediatrics 1
John Doe
10
5
4
Orthopedics 12
David Anderson
7
6
5
Dermatology 4
Michael Williams
5
7
5
Dermatology 32
Joshua Wright
5
8 5
Dermatology 39
Virginia Nelson
5
9
6
Radiology 49
Sharon Edwards
7
10
7
Oncology 30
Anthony Allen
7
11 8
Emergenc... 43
Justin Roberts
8
12 9
13
10
Psychiatry 24
General S...
48
George Rodrigu... 4
Keith Evans
10
Picture 6.1
Question 7:
Write a query to display, for each department, the number of distinct patients who have appointments with a doctor in that department for the years 2022, 2023 and 2024. The results must include DepartmentID, Name, NumberOfPatientsIn2022,NumberOfPatientsIn2023 and NumberOfPatientsIn2024, as shown in the following figure.
Note that all departments must be displayed in the results.
NumberOfPatientsIn2022 NumberOfPatientsin2023 NumberOfPatientsin2024
DepartmentID Name
1
1
Cardiology 5
4
17
2
2
Neurology 6
7
9
3
3
Pediatrics 5
8
13
4
4
Orthopedics 3
2
15
5 5
Dermatology 4
1
15
6 6
Radiology 2 1
2
6
7
7
Oncology
3
8
8
8
Emergenc... 6
5
10
9 9
Psychiatry 0
1
6
10 10
General S... 10
6
12
Picture 7.1
Question 8:
Create a function named F2 which calculates and returns an integer number which is the number of distinct patients who were required to do a given test during their appointments.
+ 91%
Close