SOL-C01 · Question #78
SOL-C01 Question #78: Real Exam Question with Answer & Explanation
The correct answer is B: `sql SELECT FROM ORDERS WHERE ORDER DATE BETWEEN '2023-01-01' AND '2023-01-. Using a 'BETWEEN' operator with specific date values (Option B) is generally the most efficient way to filter data based on a date range in Snowflake. It allows Snowflake to utilize indexing (if available) and optimize the query execution plan. Options A and D, using functions li
Question
You have a table named 'ORDERS' with a column 'ORDER DATE of data type DATE. You need to write a SQL query to retrieve all orders placed in the month of January 2023. Which of the following queries is the MOST efficient way to achieve this in Snowflake?
Options
- ASELECT FROM ORDERS WHERE = 1 AND = 2023;
- B`sql SELECT FROM ORDERS WHERE ORDER DATE BETWEEN '2023-01-01' AND '2023-01-
- CSELECT FROM ORDERS WHERE 'YYYY-MM') = '2023-01';
- D`sql SELECT FROM ORDERS WHERE DATE PART(month, ORDER DATE) = 1 AND DATE
- ESELECT FROM ORDERS WHERE ORDER_DATE LIKE '2023-01%'
Explanation
Using a 'BETWEEN' operator with specific date values (Option B) is generally the most efficient way to filter data based on a date range in Snowflake. It allows Snowflake to utilize indexing (if available) and optimize the query execution plan. Options A and D, using functions like 'MONTH' and 'YEAR' or 'DATE_PART , prevent index usage and require Snowflake to evaluate the function for every row. Option C, converting the date to a string using TO_CHAR , is also inefficient for the same reason. Option E, using LIKE', is unsuitable for date comparisons and would not be performant, and could also potentially return incorrect results.
Topics
Community Discussion
No community discussion yet for this question.