CS FundamentalsHardTCS Digital · Infosys SP · GATE CS
Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia'). Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). Table Course(cid, credits) rows: ('C1', 4), ('C2', 3), ('C3', 2), ('C4', 3). What does this query return?
Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia').
Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50).
Table Course(cid, credits) rows: ('C1', 4), ('C2', 3), ('C3', 2), ('C4', 3).
What does this query return?
SELECT s.sname, SUM(c.credits)
FROM Stu s JOIN Takes t ON s.sid = t.sid
JOIN Course c ON c.cid = t.cid
GROUP BY s.sid, s.sname
ORDER BY s.sid;- A. (Om, 7), (Pia, 4), (Raj, 3)
- B. (Om, 7), (Pia, 4), (Raj, 5), (Sia, 0)
- C. (Om, 4), (Pia, 4), (Raj, 5)
- D. (Om, 7), (Pia, 4), (Raj, 5)
Correct answer: D. (Om, 7), (Pia, 4), (Raj, 5)
Om took C1 (4) and C2 (3) = 7 — his NULL marks don't matter to credits; Pia C1 = 4; Raj C2 + C3 = 5. Sia has no Takes row and an inner join drops her.
More DBMS and SQL questions
- A B+ tree index uses 4096-byte blocks, 20-byte search keys, 12-byte block (tree) pointers and 14-byte record pointers. What is the maximum…
- For the schedule W1(C), W2(C), R2(B), R3(A), W4(C), R4(C), R3(B), R1(B), how many serial schedules of T1–T4 are conflict-equivalent to it?
- Extendible hashing uses the LOWEST-order bits of a key's binary value, bucket capacity 2, and starts with global depth 0 and one empty…
- R(A, B, C, D, E) has functional dependencies C → E, AC → DE, E → D, BC → DE, AD → CE. How many prime attributes does R have?
- In a wait-for graph, T1 waits for T2, T2 waits for T3, T3 waits for T4 and T4 waits for T2. T5 waits for T1. Which transactions are…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…