CS FundamentalsModerateGATE CS · SQL
Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?
Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2).
What does this query return?
SELECT COUNT(*), COUNT(dept), COUNT(DISTINCT dept), COUNT(pay) FROM Staff;
- A. 6, 5, 3, 5
- B. 6, 6, 3, 6
- C. 6, 5, 2, 5
- D. 5, 5, 2, 5
Correct answer: C. 6, 5, 2, 5
COUNT(*) counts rows (6); COUNT(col) skips NULLs (dept 5, pay 5); COUNT(DISTINCT dept) also ignores NULL, leaving Ops and Tech = 2.
More DBMS and SQL questions
- R(A, B, C, D, E) has functional dependencies B → ACD, BC → AD, C → A. What is the closure {B}⁺?
- Which statement about the multivalued dependency X ↠ Y on R is correct?
- R(A, B, C, D, E) has the set of functional dependencies Σ = {AD → BE, D → AE, CE → D, A → B}. Which of the following FDs is NOT in Σ⁺ (not…
- A file of 2400 blocks is sorted by external merge sort with M = 6 buffer blocks (sorted runs of M blocks are created in pass 0, then (M −…
- R(A1, A2, …, A8) has the FDs A1 → A2, A2 → A3, …, A7 → A8 and A8 → A1. How many candidate keys does R have, and what is its highest normal…
- Assertion (A): Every relation schema with exactly two attributes is in BCNF. Reason (R): For R(X, Y), any non-trivial FD has a single…