CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ
Table T has 7 rows. What does SELECT COUNT(*) FROM T HAVING COUNT(*) > 10; return? (Standard SQL; SQLite accepts HAVING without GROUP BY from 3.39.)
- A. One row containing 0
- B. One row containing 7
- C. An error, since HAVING needs GROUP BY
- D. No rows at all
Correct answer: D. No rows at all
Without GROUP BY the whole table is a single group of 7 rows; HAVING tests that group, 7 > 10 is false, so the group and hence the only output row is removed. The result is empty, not 0.
More DBMS and SQL questions
- Table U(x INT UNIQUE) is empty. These statements run one at a time: INSERT (1); INSERT (NULL); INSERT (NULL); INSERT (1). How many succeed…
- Table K(amt INT CHECK (amt > 0)) is empty. These run one at a time: INSERT (-5); INSERT (NULL); INSERT (0); INSERT (3). How many rows does…
- P(id PRIMARY KEY) has rows 1, 2. C(id, pid REFERENCES P ON DELETE CASCADE) has (10, 1), (11, 1), (12, 2). G(id, cid REFERENCES C ON DELETE…
- R(A, B, C) is decomposed into R1(A, B) and R2(B, C). Which condition is necessary and sufficient (under FDs only) for the decomposition to…
- R(A, B, C) with FDs A → B and B → C has primary key A. A designer moves to R1(A, B) and R2(B, C). Which statement is correct?
- In a wait-for graph the edges are T1 → T2, T2 → T3, T3 → T1, T3 → T4 and T5 → T2. What is the minimum number of transactions that must be…