nerdexam
SnowflakeSnowflake

SOL-C01 · Question #29

SOL-C01 Question #29: Real Exam Question with Answer & Explanation

The correct answer is C: Option C. DATE TRIJNC is the most efficient way to truncate dates to a specified level (month in this case) and allows for accurate grouping (C). It also takes advantage of Snowflake's date functions optimized for performance. Using MONTH and YEAR (A, B) are functional, but less performant

Querying and Performance

Question

A Snowflake table 'ORDERS' contains a 'ORDER DATE' column of data type DATE. You need to write a query that returns the order count for each month in the year 2023. Which of the following SQL snippets is MOST efficient and accurate for achieving this?

Options

  • AOption A
  • BOption B
  • COption C
  • DOption D
  • EOption E

Explanation

DATE TRIJNC is the most efficient way to truncate dates to a specified level (month in this case) and allows for accurate grouping (C). It also takes advantage of Snowflake's date functions optimized for performance. Using MONTH and YEAR (A, B) are functional, but less performant than DATE TRUNC. While D works, converting to a CHAR and then grouping is less efficient. E retrieves the month name, which wasn't the requirement, and month names may not group correctly due to localization settings. Using BETWEEN on the DATE column is also more efficient than extracting year and comparing as it leverages indexing when available.

Topics

#SQL Querying#Date Functions#Aggregation#Filtering

Community Discussion

No community discussion yet for this question.

Full SOL-C01 PracticeBrowse All SOL-C01 Questions