
Answer-first summary for fast verification
Answer: Change WHERE year = 2023 to WHERE extract(year FROM sales_data) = 2023.
The `year` keyword might be a reserved word or the column containing dates is properly formatted as a timestamp in the source. Using the `extract` function is the standard SQL way in Athena (Presto) to extract the year from a date or timestamp column, ensuring the query executes accurately without missing records.
Author: Ritesh Yadav
Ultimate access to all questions.
query does not return results for all of the products that are in the sales_data table. The data engineer needs to troubleshoot the query to resolve the issue.
The data engineer's original query is:
SELECT product_name, sum(sales_amount) FROM sales_data WHERE year = 2023 GROUP BY product_name
How should the data engineer modify the Athena query to meet these requirements?
A
Replace sum(sales_amount) with count(*) for the aggregation.
B
Change WHERE year = 2023 to WHERE extract(year FROM sales_data) = 2023.
C
Add HAVING sum(sales_amount) > 0 after the GROUP BY clause.
D
Remove the GROUP BY clause.
No comments yet.