Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help writing SQL for SQL Server. The question is : Question 5: (more contro

ID: 3784464 • Letter: N

Question

Need help writing SQL for SQL Server.

The question is :

Question 5: (more controls): If a student becomes a senior, you need to lower his/her maximum number of books to borrow from 4 (four) to 2 (two).

We have a student table. The student table contains a column called studentstatus which can hold the value of 0 or 1. 1 is for seniors and 0 is for juniors. We also have another column in the student table called Totalallowed int. Total allowed is the number of books that can be borrowed.

I just need to write a query to be able to lower the max books if the student is a senior.

Explanation / Answer

Update Student set Totalallowed = Totalallowed -2 where studentstatus = 1;

Here in Student table , the update query will update all rows and set the new value to lower the maximum number of books to borrow from 4 to 2. The Totalallowed column is decreased by 2 where studentstatus = 1 ie student has become a senior.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote