DML & Transactions · Question 16 · Hard

DML & Transactions question 16

Table Wallet:
user_name | points
Lalit | 100
Mona | NULL
Nitin | 50

Every user is given 50 festival points. What does the SELECT return after the UPDATE?

UPDATE Wallet SET points = points + 50;
SELECT user_name, points FROM Wallet ORDER BY user_name;
  1. Lalit, 150; Mona, 50; Nitin, 100
  2. Lalit, 150; Mona, NULL; Nitin, 100
  3. Lalit, 150; Nitin, 100
  4. Lalit, 150; Mona, 0; Nitin, 100
Answer and explanation

Answer: B. Lalit, 150; Mona, NULL; Nitin, 100

Explanation: For Mona, points + 50 is NULL + 50, which is NULL, so her points stay NULL. To give her 50, the statement should use COALESCE(points, 0) + 50.

Previous: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |… · Next: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…

Practise dml & transactions

Try a fresh set of dml & transactions questions with an explanation after every answer, free and without signing up: DML & Transactions practice. Or sit a full placement mock test.

More dml & transactions questions

More sql practice

SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge