CS FundamentalsModerateGATE CS
Table T(x) holds the values 1, NULL, 3, NULL, 3. What does SELECT COUNT(*), COUNT(x), COUNT(DISTINCT x) FROM T return?
- A. 5, 3, 2
- B. 5, 5, 3
- C. 3, 3, 2
- D. 5, 3, 3
Correct answer: A. 5, 3, 2
COUNT(*) counts all 5 rows, COUNT(x) skips NULLs (3), and COUNT(DISTINCT x) counts the distinct non-NULL values 1 and 3 (2).
More DBMS and SQL questions
- Emp(n, dept, sal) has rows (A, d1, 40), (B, d1, 70), (C, d2, 45), (D, d2, 50), (E, d3, 80), (F, d3, 30), (G, d4, 60). How many rows does…
- Dept(d) has rows 1, 2, 3 and Emp(e, d) has rows (a, 1), (b, 1), (c, 2). How many rows does SELECT D.d FROM Dept D LEFT JOIN Emp E ON D.d =…
- R(A, B, C, D) has the functional dependencies AB -> C, C -> D and D -> A. How many candidate keys does R have?
- S(v) has rows 1, 2, 3 and U(v) has rows 2, NULL. What does SELECT COUNT() FROM S WHERE v NOT IN (SELECT v FROM U) return?
- A(x) holds 1, 2, 2, 3 and B(x) holds 2, 3, 3, 4. How many rows does SELECT x FROM A UNION SELECT x FROM B return?
- R(A, B, C) has the functional dependencies AB -> C and C -> B. Which is the highest normal form that R satisfies?