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,where testID int is the input parameter of the function.
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)
TestID
Name
NumberOfPatients
5
2
5
1
9 Thyroid Test
2 10 Liver Function Test
3
4
11
12
Kidney Function Test
Complete Blood Count 8
Question 9:
Picture 8.1
Create a trigger named insertDoctor for the INSERT statement on the "Doctors" table so that
Close
+ 94%
Zoom