107k views
4 votes
Structure of the ORDERS table / Structure of the CUSTOMERS table

Which of the following SQL statements will return the names of all customers who placed an order on April 12, 2003?

a) SELECT firstname, lastname
FROM customers
WHERE order_date = '2003-04-12';

b) SELECT firstname, lastname
FROM customers
JOIN orders ON customers.customer# = orders.customer#
WHERE order_date = '2003-04-12';

c) SELECT firstname, lastname
FROM orders
JOIN customers ON customers.customer# = orders.customer#
WHERE order_date = '2003-04-12';

d) SELECT firstname, lastname
FROM orders
WHERE order_date = '2003-04-12';

1 Answer

3 votes

Final answer:

The correct SQL statement to get the names of customers who placed an order on April 12, 2003, is by joining the CUSTOMERS table with the ORDERS table and filtering the results by the order_date.

Step-by-step explanation:

To find the names of all customers who placed an order on April 12, 2003, you would need to join the CUSTOMERS table with the ORDERS table based on a common key, usually the customer identifier. Then you can filter the result to only show orders from the specified date. The correct SQL is the option that includes a JOIN operation and selects the first name and last name from the CUSTOMERS table while filtering on the order_date in the ORDERS table.

So, the correct SQL statement is:

b) SELECT firstname, lastname FROM customers JOIN orders ON customers.customer# = orders.customer# WHERE order_date = '2003-04-12';

User Liao Zhuodi
by
8.2k points