Databricks Certified Data Analyst Associate · Free Practice Question Medium
Question 9
Given a database with a table Orders containing columns OrderId, CustomerId, OrderDate, and Amount, you want to retrieve the list of orders placed by a particular customer, identified by CustomerId = 123, where the order amount is greater than $500.
Which SQL query will correctly retrieve this data?
-
A
SELECT CustomerId, Amount FROM Orders WHERE OrderId = 123 AND Amount > 500; -
B
DELETE FROM Orders WHERE CustomerId = 123 AND Amount > 500; -
C
SELECT * FROM Orders WHERE CustomerId = 123 AND Amount > 500; -
D
SELECT OrderId FROM Orders WHERE CustomerId = 123 OR Amount > 500; -
E
UPDATE Orders SET Amount = 500 WHERE CustomerId = 123;
Reveal correct answer
Correct answer: C
Explanation
The correct answer, "SELECT * FROM Orders WHERE CustomerId = 123 AND Amount > 500," effectively identifies the query that meets the specified conditions. This SQL query retrieves all records from the 'Orders' table where the 'CustomerId' is 123 and the 'Amount' is greater than $500. The use of the AND operator ensures both conditions must be met simultaneously, thereby filtering the orders specifically for the given customer and the minimum order amount criterion.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
