
Answer-first summary for fast verification
Answer: select * from testtable sample (10);
The question asks for a query that returns a sample where each row has a 10% probability of being included. In Snowflake, the SAMPLE clause uses a decimal value between 0 and 1 to represent the sampling probability. Option B uses SAMPLE (10), which is equivalent to 10% (10/100 = 0.1), correctly implementing a 10% probability for each row. Option A uses SAMPLE (0.1), which represents 0.1% probability, not 10%. Option C uses SAMPLE (0.1 rows), which attempts to specify a row count but with an invalid syntax for probability sampling. Option D uses SAMPLE (10 rows), which specifies an exact row count rather than a probability, and would return exactly 10 rows, not a 10% probability sample. The community discussion shows 100% consensus on B, with references to Snowflake documentation confirming that SAMPLE (n) uses n as a percentage.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
Which query will return a sample of 1000 rows from a table named testtable, where each row has a 10% probability of being included in the sample?
A
select * from testtable sample (0.1);
B
select * from testtable sample (10);
C
select * from testtable sample (0.1 rows);
D
select * from testtable sample (10 rows);