CS FundamentalsHardProduct placement · SQL round
Table Acct(no, branch, bal) rows: (101, 'Agra', 500), (102, 'Agra', 1500), (103, 'Bhopal', 700), (104, 'Bhopal', 700), (105, 'Cuttack', 2000), (106, 'Agra', NULL). What does this query return?
Table Acct(no, branch, bal) rows: (101, 'Agra', 500), (102, 'Agra', 1500), (103, 'Bhopal', 700), (104, 'Bhopal', 700), (105, 'Cuttack', 2000), (106, 'Agra', NULL).
What does this query return?
SELECT branch FROM Acct GROUP BY branch HAVING COUNT(DISTINCT bal) = COUNT(bal) ORDER BY branch;
- A. Bhopal
- B. Cuttack
- C. Agra, Bhopal, Cuttack
- D. Agra, Cuttack
Correct answer: D. Agra, Cuttack
Bhopal has two equal balances (700, 700), so its distinct count 1 ≠ 2. Agra's non-NULL balances 500 and 1500 are distinct (the NULL is ignored by both counts), and Cuttack has one.
More DBMS and SQL questions
- R(A, B, C, D, E, F) with functional dependencies E → B, F → A, B → A, C → E is decomposed into R1(A, B, F), R2(B, D, E), R3(C, E). Which…
- On R(A, B, C, D, E), F = {AB → C, DE → C, B → C} and G = {B → DE, E → AC, D → A}. Which statement is correct? ("F covers G" means every FD…
- R(A, B, C, D, E, F) has FDs E → AB, C → A, DE → AB, B → EF. Each option is a relation schema obtained by projecting R, with the…
- Classify the schedule W3(B), R1(A), W1(B), C1, W2(A), W3(A), R2(A), W2(B), C3, C2 (Ci = commit of Ti) by the strongest property it…
- A B+ tree has at most 10 children per internal node and at most 8 keys per leaf. A non-root internal node must have at least ⌈10/2⌉…
- Which tuple relational calculus expression is UNSAFE (may produce an infinite result)?