CS FundamentalsHardTCS 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 COUNT(DISTINCT bal), COUNT(bal), SUM(DISTINCT bal) FROM Acct;
- A. 4, 5, 4700
- B. 4, 5, 5400
- C. 4, 6, 4700
- D. 5, 5, 5400
Correct answer: A. 4, 5, 4700
Non-NULL balances: 500, 1500, 700, 700, 2000. COUNT(bal) = 5; DISTINCT values are 500, 700, 1500, 2000 (4) summing to 4700; the plain sum would be 5400.
More DBMS and SQL questions
- R(A, B) = {(2, 4), (3, 1), (4, 1), (4, 3), (4, 4)} and S(B, C) = {(1, 5), (2, 7), (4, 6), (4, 7)}. How many tuples are in R ⟕ S (left…
- R(A, B, C, D, E) has functional dependencies B → C, A → BE, C → ABE, E → C. Which of the following is the complete set of candidate keys…
- T1: W1(A), R1(A), W1(B) and T2: W2(A), R2(B). Of all 10 interleavings that keep each transaction's own order, how many are conflict…
- Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). What does this…
- R(A, B) = {(1, 1), (1, 2), (1, 4), (2, 2), (4, 2), (4, 4)} and S(B, C) = {(1, 5), (3, 5), (3, 6), (4, 7)}. What is πA(R) − πA(R ⋈ S)?
- R(A, B) = {(1, 4), (2, 1), (2, 4), (3, 2), (3, 3), (4, 4)} and S(B, C) = {(1, 6), (1, 7), (2, 5), (2, 6)}. What is πA(R) − πA(R ⋈ S)?