DBI202_-_FA_2024_-_PE_-_s_-_12_2891.webp
Pride2003

DBI202_-_FA_2024_-_PE_-_s_-_12_2891.webp

For example, when we call the F1 function in the following query for calculating the number of distinct patients having appointments with the two departments 'Cardiology' and 'Pediatrics', the results must be shown as in the following figure:
select DepartmentID, Name, dbo. F1 (DepartmentID) as NumberOfPatients
from Departments
where Departments.Name in ('Cardiology', 'Pediatrics')
DepartmentID
1
3
Name
NumberOfPatients
Cardiology 37
Pediatrics
32
1
2
Picture 8.1
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'.
For example, if we execute the following statements to insert two doctors (one with DepartmentID=NULL and the other with DepartmentID=5) and then select these two doctors,

Close
+ 100%
Zoom
Chưa có bình luận nào.

Thông tin

Category
DBI202
Thêm bởi
Pride2003
Ngày thêm
Lượt xem
841
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
DBI202_-_FA_2024_-_PE_-_s_-_12_2891.webp
File size
238 KB
Dimensions
1920px x 803px

Share this media

Back
Bên trên Bottom