Which of the following SQL command will help in incrementing values of FEES…
2023
Which of the following SQL command will help in incrementing values of FEES column in STUDENT table by 10%?
- A.
UPDATE STUDENT
ASSIGN FEES=FEES * 1.1;
- B.
UPDATE STUDENT
SET FEES=FEES * 1.1;
- C.
UPDATE STUDENT
SET FEES=FEES * 10%;
- D.
UPDATE STUDENT
SET FEES 10%;
Attempted by 1766 students.
Show answer & explanation
Correct answer: B
Key idea: To increase FEES by 10%, multiply the current value by 1.1 (100% + 10% = 110% = 1.1).
Correct SQL to update all rows:
UPDATE STUDENT SET FEES = FEES * 1.1;
If you only want to change some rows, add a WHERE clause, for example: UPDATE STUDENT SET FEES = FEES * 1.1 WHERE <condition>;
Why the other statements are incorrect:
Using ASSIGN is not valid SQL for UPDATE; the proper keyword is SET to assign an expression to a column.
Writing FEES * 10% is invalid: the percent sign is not a numeric literal in SQL (and % can mean modulo in some dialects). To add 10% use FEES * 1.1 or FEES + FEES * 0.10.
The fragment SET FEES 10% is syntactically incomplete and missing the '=' and a valid expression; it should be SET FEES = FEES * 1.1.
A video solution is available for this question — log in and enroll to watch it.