
Answer-first summary for fast verification
Answer: CREATE TABLE recent_orders AS SELECT * FROM orders WHERE order_date >= current_date() - interval 30 days
The correct answer is A because it correctly uses the 'current_date() - interval 30 days' expression to filter orders from the last 30 days and creates a new table 'recent_orders' with these filtered rows.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You are working with a Delta Lake table 'orders' that contains columns 'order_id', 'customer_id', and 'order_date'. You need to create a new table 'recent_orders' that includes only the orders from the last 30 days. Write the Spark SQL query to achieve this.
A
CREATE TABLE recent_orders AS SELECT * FROM orders WHERE order_date >= current_date() - interval 30 days
B
CREATE TABLE recent_orders AS SELECT * FROM orders WHERE order_date >= date_sub(current_date(), 30)
C
CREATE TABLE recent_orders AS SELECT * FROM orders WHERE order_date >= add_months(current_date(), -1)
D
CREATE TABLE recent_orders AS SELECT * FROM orders WHERE order_date >= date_add(current_date(), -30)
No comments yet.