CS FundamentalsModerateTCS Digital · Infosys SP · GATE CS
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, COUNT(*) FROM Acct GROUP BY branch HAVING SUM(bal) >= 1400 ORDER BY branch;
- A. (Bhopal, 2), (Cuttack, 1)
- B. (Agra, 3), (Bhopal, 2), (Cuttack, 1)
- C. (Agra, 3), (Cuttack, 1)
- D. (Agra, 2), (Bhopal, 2), (Cuttack, 1)
Correct answer: B. (Agra, 3), (Bhopal, 2), (Cuttack, 1)
Agra's SUM ignores the NULL: 2000; Bhopal 1400 (≥ is inclusive); Cuttack 2000. COUNT(*) counts all of Agra's 3 rows, including the NULL balance.
More DBMS and SQL questions
- R(A, B) = {(1, 4), (3, 4), (4, 1), (4, 3), (4, 4)} and S(B, C) = {(2, 5), (2, 7), (3, 5), (4, 6)}. How many tuples are in R ⟕ S (left…
- Entity sets Doctor, Patient and Drug participate in a single ternary relationship Prescribes with no cardinality constraints. Each entity…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- For the schedule W3(A), W3(C), R2(A), R1(A), W1(B), W4(A), R2(C), W4(B), how many serial schedules of T1–T4 are conflict-equivalent to it?
- R(A, B, C, D, E, F) has functional dependencies EF → D, A → C, BE → F, F → A, DF → A. What is the highest normal form R satisfies?
- Table Sale(id, rep, region, amt) rows: (1, 'Ira', 'N', 100), (2, 'Jai', 'S', 250), (3, 'Ira', 'S', NULL), (4, 'Kim', 'N', 300), (5, 'Jai'…