CS FundamentalsModerateTCS NQT · Product-company placement
Emp(eid, name, mgr, sal) has rows (1, Kiran, NULL, 100), (2, Lata, 1, 80), (3, Mohan, 1, 120), (4, Neha, 2, 90), (5, Om, 4, 60), (6, Pari, 3, 130). Which names does this return? SELECT e.name FROM Emp e WHERE e.sal > (SELECT m.sal FROM Emp m WHERE m.eid = e.mgr);
- A. Mohan and Pari
- B. Kiran, Mohan, Neha and Pari
- C. Mohan only
- D. Mohan, Neha and Pari
Correct answer: D. Mohan, Neha and Pari
Mohan 120 > Kiran 100, Neha 90 > Lata 80 and Pari 130 > Mohan 120; Om 60 < Neha 90. For Kiran the subquery is empty, giving NULL, and 100 > NULL is UNKNOWN, so Kiran is not returned.
More DBMS and SQL questions
- Using Emp(eid, name, mgr, sal) with rows (1, Kiran, NULL, 100), (2, Lata, 1, 80), (3, Mohan, 1, 120), (4, Neha, 2, 90), (5, Om, 4, 60)…
- Fee(sid, fee) has rows (1, 500), (2, 700), (3, 700), (4, 400), (5, 900), (6, 400). What does this return? SELECT SUM(fee) FROM Fee f WHERE…
- Player(pid, team, runs) has rows (1, 'A', 50), (2, 'A', 70), (3, 'A', 70), (4, 'B', 40), (5, 'B', NULL), (6, 'B', 90), (7, 'C', NULL)…
- Cust(cid, city) has rows (1, 'Pune'), (2, 'Delhi'), (3, NULL), (4, 'Pune'). What are the values of Q1: SELECT COUNT() FROM (SELECT city…
- Ord(oid, cid, amt) has no row with cid = 99. What do these return? Q1: SELECT SUM(amt), COUNT() FROM Ord WHERE cid = 99; Q2: SELECT cid…
- R(A, B, C, D, E, F) has functional dependencies AB → C, C → D, D → E, E → A and F → B. How many superkeys does R have?