
Answer-first summary for fast verification
Answer: select * from ORDERS tablesample (10 rows);
The question asks for a query that returns exactly 10 randomly sampled rows from the ORDERS table every time it's run. Option D uses the correct Snowflake syntax `TABLESAMPLE (10 ROWS)` which performs fixed-size row sampling and returns exactly 10 random rows. Option A (`FETCH 10`) is incorrect as FETCH is used for pagination with ORDER BY, not random sampling. Option B (`LIMIT 10`) returns the first 10 rows based on the query's ordering, not random rows. Option C (`SAMPLE (10)`) is close but incomplete - the SAMPLE clause requires specifying either a percentage or number of rows explicitly (like `SAMPLE (10 ROWS)`), and the syntax shown would be interpreted as a percentage (10% of 12,000 rows = 1,200 rows), not 10 fixed rows. The community discussion with 100% consensus on D and the referenced Snowflake documentation confirms that TABLESAMPLE (n ROWS) is the correct approach for fixed-size random sampling.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.