DML & Transactions · Question 18 · Hard
DML & Transactions question 18
Table Account:
acc_no | holder | balance
101 | Farah | 5000
102 | Gopal | 12000
103 | Hema | 800
104 | Imran | 7000
Table Closed:
acc_no
101
NULL
The DELETE is meant to remove every account that is not listed in Closed. How many rows does Account hold afterwards?
DELETE FROM Account
WHERE acc_no NOT IN (SELECT acc_no FROM Closed);
SELECT COUNT(*) FROM Account;
- 4
- 1
- 3
- 0
Answer and explanation
Answer: A. 4
Explanation: The subquery returns 101 and NULL. acc_no NOT IN (101, NULL) is FALSE for 101 and UNKNOWN for every other account, never TRUE, so the DELETE removes no rows and all 4 remain.
Previous: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |… · Next: Table Coupon(code PRIMARY KEY) holds one row, DIWALI. In PostgreSQL, MySQL…
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 Wallet: user_name | points Lalit | 100 Mona | NULL Nitin | 50 Every user…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Coupon(code PRIMARY KEY) holds one row, DIWALI. In PostgreSQL, MySQL…
- Table Customer: id | name | total 1 | Omkar | 0 2 | Pallavi | 0 3 | Qasim | 0…
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