Paper No: 7
NumberOfMaleMembers and NumberOfFemale Members are respectively the number of distinct male members and female members who have borrowed in the year 2020 (based on LoanDate) books belonging to each book genre. Note that all book genres must be displayed in the results as in the following figure.
GenrelD
GenreName
NumberOfMaleMembers
NumberOfFemale Members
1
1
Science Fiction
6
2
2
2
Fantasy
4
1
3
3
Mystery
3
2
4
4
Thriller
0
0
5
5
Romance
9
7
6
6
Historical Fiction 1
4
7
7
Biography
2
1
8
8
Horror
2
1
9
9
Adventure
4
3
10 10
Poetry
4
2
Picture 7.1
Question 8:
Create a stored procedure named insertAuthor with @authorID int, @author Name nvarchar(100), @country nvarchar(100), @sex nvarchar(10), @yearOfBirth int as input parameters of the procedure. The stored procedure attempts to insert a new author into the table Authors, but only if an author with the same AuthorID does not already exists:
- if an author with AuthorID = @authorID already exists, the procedure does nothing.
- if there is no author with AuthorID = @authorID, the procedure will insert into the table Authors a new row with @authorID, @authorName, @country, @sex, @yearOfBirth as
values for its attributes.
Zoom
For example, when we execute the insertAuthor procedure with input values as in the following statement, a new author with the corresponding values will be inserted into the
+ 100%
Close