
Answer-first summary for fast verification
Answer: SELECT * FROM MY_TABLE SAMPLE (5 ROWS);
The question asks for a sampling query that will ALWAYS return exactly 5 rows from a 10-row table. Option C (SELECT * FROM MY_TABLE SAMPLE (5 ROWS);) is the correct choice because it explicitly specifies a fixed number of rows (5) to return, ensuring consistent results regardless of the table's size or content. In contrast, Option A (SYSTEM (5)) and Option B (BERNOULLI (5)) use percentage-based sampling (5% of 10 rows = 0.5 rows, rounded up to 1 row), which would return approximately 1 row, not 5. Option D (SYSTEM (1) SEED (5)) also uses percentage-based sampling (1% of 10 rows = 0.1 rows, rounded up to 1 row) with a seed for reproducibility, but still returns only 1 row. The community discussion confirms this with 100% consensus on Option C.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Given a table named MY_TABLE containing 10 rows, which of the following sampling queries is guaranteed to return exactly 5 rows?
A
SELECT * FROM MY_TABLE SAMPLE SYSTEM (5);
B
SELECT * FROM MY_TABLE SAMPLE BERNOULLI (5);
C
SELECT * FROM MY_TABLE SAMPLE (5 ROWS);
D
SELECT * FROM MY_TABLE SAMPLE SYSTEM (1) SEED (5);
No comments yet.