SnowPro Associate: Platform Question 183
Single answer○ LIMITA data analyst is troubleshooting a query in Snowflake against a SALES table that contains billions of rows. They only want to quickly inspect a small sample of rows while validating column names and basic values, and they do not care which specific rows are returned. Which approach best fits this requirement?
- A
Run a SELECT statement with LIMIT 100 and no ORDER BY clause
- B
Run a SELECT statement with ORDER BY every column and LIMIT 100 to reduce the amount of scanned data
- C
Use LIMIT 100 because it guarantees the same 100 rows will be returned every time, even without sorting
- D
Use LIMIT 100 in the FROM clause so Snowflake restricts the table scan before query execution
Show answer and explanation
Correct answer: A
Explanation
In Snowflake, LIMIT is commonly used to restrict the number of rows returned by a query, which is especially helpful for previewing data and testing SQL against large tables. However, LIMIT alone does not define row order. If deterministic results are required, it should be paired with ORDER BY. For practical troubleshooting, using SELECT ... LIMIT n without ORDER BY is appropriate when any subset of rows is acceptable. Snowflake documentation for SELECT notes that LIMIT restricts the number of rows in the result set, while ORDER BY controls the order of returned rows.
- A. Correct.
Correct. LIMIT restricts the number of rows returned to the client, which is useful for quickly previewing data during development or troubleshooting. Because the analyst does not care which rows are returned, omitting ORDER BY is appropriate. Without ORDER BY, the returned rows are not guaranteed to be in any particular order, but for a quick inspection that is acceptable.
- B. Incorrect.
Incorrect. Adding ORDER BY every column is unnecessary for a simple preview and can increase work because Snowflake may need to sort the result set before applying the LIMIT. ORDER BY is only appropriate when the analyst needs a deterministic top-N result based on a defined sort order.
- C. Incorrect.
Incorrect. LIMIT does not guarantee repeatable or deterministic results by itself. Without ORDER BY, Snowflake does not guarantee which rows are returned, so the same query can return different rows across executions.
- D. Incorrect.
Incorrect. LIMIT is not placed in the FROM clause. It is part of the query result set restriction, typically used after SELECT ... FROM ... [ORDER BY ...] LIMIT n. It does not function as a table-level syntax element in the FROM clause.