DML & Transactions · Question 12 · Medium
DML & Transactions question 12
Table Account:
acc_no | holder | balance
101 | Farah | 5000
102 | Gopal | 12000
103 | Hema | 800
104 | Imran | 7000
The two UPDATEs run one after the other. What does the SELECT return?
UPDATE Account SET balance = balance * 2
WHERE balance < 6000;
UPDATE Account SET balance = balance - 1000
WHERE balance >= 10000;
SELECT acc_no, balance FROM Account
WHERE acc_no IN (101, 102) ORDER BY acc_no;
- 101, 10000; 102, 11000
- 101, 10000; 102, 12000
- 101, 9000; 102, 11000
- 101, 9000; 102, 12000
Answer and explanation
Answer: C. 101, 9000; 102, 11000
Explanation: The first UPDATE doubles balances below 6000, so account 101 becomes 10000 (102 is untouched). The second UPDATE sees the new values: both 10000 and 12000 are at least 10000, so each loses 1000, giving 9000 and 11000.
Previous: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |… · Next: A session is in autocommit mode (the default in MySQL, PostgreSQL and SQLite)…
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
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- A session is in autocommit mode (the default in MySQL, PostgreSQL and SQLite)…
- Table Cart: item | qty Rice | 1 Which items does the SELECT return after these…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Wallet: user_name | points Lalit | 100 Mona | NULL Nitin | 50 Every user…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Coupon(code PRIMARY KEY) holds one row, DIWALI. In PostgreSQL, MySQL…
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