Create a function named F2 which calculates and returns an integer number which is the Kizspy. meper of distinct patients who were required to do a given test during their appointments,where testID int is the input parameter of the function.
6 of 6
Paper No: 4
For example, when we call the F2 function in the following query for calculating the number of distinct patients who were required to do each of the four tests with testID respectively 9,10, 11 and 12, the results must be shown as in the following figure:
select TestID, Name, dbo. F2(TestID) as NumberOfPatients
from Tests
where TestID in (9,10,11,12)
1
TestID
Name
NumberOfPatients
9
Thyroid Test
5
2
10
Liver Function Test
2
3
11
Kidney Function Test
Complete Blood Count
5
4
12
Picture 8.1
8
Question 9:
Create a trigger named insertDoctor for the INSERT statement on the "Doctors" table so that when we execute an insert statement to add one or more rows to the "Doctors" table, if any of the inserted rows have the DepartmentID as null, the system will automatically set the DepartmentID of those rows to the DepartmentID of the department named 'Cardiology'.
Zoom
For example, if we execute the following statements to insert two doctors (one with
+ 91%
Close