nerdexam
SnowflakeSnowflake

SOL-C01 · Question #86

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

The correct answer is A: SELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE order_date =. Option A is the correct query. It filters the data for the specific date, groups the results by `customer_id' to calculate the total order amount for each customer, orders the results in descending order based on the total amount, and then limits the output to the top 5 customers

Querying and Performance

Question

You have a table named 'CUSTOMER ORDERS with columns `customer id', `order date' , and 'order amount'. You want to retrieve the top 5 customers who placed orders on a specific date ('2023-01-15') based on the total order amount. Which SQL query will achieve this?

Options

  • ASELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE order_date =
  • BSELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS GROUP BY customer_id
  • CSELECT customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE order_date =
  • DSELECT customer_id, order_amount FROM CUSTOMER_ORDERS WHERE order_date = '2023-
  • E`sql SELECT TOP 5 customer_id, AS total_amount FROM CUSTOMER_ORDERS WHERE

Explanation

Option A is the correct query. It filters the data for the specific date, groups the results by `customer_id' to calculate the total order amount for each customer, orders the results in descending order based on the total amount, and then limits the output to the top 5 customers. Option B has the WHERE clause in the wrong order. Option C misses the GROUP BY clause, resulting in only one row. Option D does not sum the order amounts. Option E is not valid Snowflake SQL; Snowflake does not use TOP clause. It is standard SQL to use the LIMIT clause.

Topics

#SQL Querying#Aggregation#Filtering Data#Top N Queries

Community Discussion

No community discussion yet for this question.

Full SOL-C01 PracticeBrowse All SOL-C01 Questions