CS FundamentalsModerateGATE CS · SQL
Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). What does this query return?
Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50).
What does this query return?
SELECT COUNT(*) FROM Takes a JOIN Takes b ON a.cid = b.cid AND a.sid < b.sid;
- A. 5
- B. 8
- C. 3
- D. 4
Correct answer: D. 4
C1 is taken by sids 1, 2, 5 → 3 pairs; C2 by 1 and 3 → 1 pair; C3 by one student. a.sid < b.sid counts each unordered pair once: 4.
More DBMS and SQL questions
- Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia'). Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2'…
- Which set of relational algebra operators is a complete (minimal) basis from which the others can be expressed?
- A B-tree (not B+ tree) stores a record pointer with every key in every node. With 1024-byte blocks, 9-byte keys, 6-byte tree pointers and…
- Two transactions each read X = 100. T1 sets X = X − 30 and commits; then T2 sets X = X + 50 and commits. The final value is 150. Which…
- Classify the schedule R2(B), W1(A), W2(A), W3(A), R1(B), W1(B), R3(A), R3(B).
- Under basic two-phase locking, a conflict-serializable schedule is equivalent to the serial schedule that orders transactions by their: