nerdexam
Oracle

1Z0-007 · Question #144

Examine the data from the ORDERS and CUSTOMERS table. Which SQL statement retrieves the order ID, customer ID, and order total for the orders that are placed on the same day that Martin places his…

The correct answer is B. SELECT ord_id, cust_id, ord_total. This query will return the order ID, customer ID, and order total for the orders that are placed on the same day that Martin places his orders. Incorrect Answers A: This query returns only Martin's orders for July 18, 2000 and July 21, 2002, not orders of others that were…

Displaying Data from Multiple Tables and Subqueries

Question

Examine the data from the ORDERS and CUSTOMERS table. Which SQL statement retrieves the order ID, customer ID, and order total for the orders that are placed on the same day that Martin places his orders?

Exhibit

1Z0-007 question #144 exhibit

Options

  • ASELECT ord_id, cust_id, ord_total
  • BSELECT ord_id, cust_id, ord_total
  • CSELECT ord_id, cust_id, ord_total
  • DSELECT ord_id, cust_id, ord_total

How the community answered

(36 responses)
  • A
    3% (1)
  • B
    83% (30)
  • C
    6% (2)
  • D
    8% (3)

Explanation

This query will return the order ID, customer ID, and order total for the orders that are placed on the same day that Martin places his orders. Incorrect Answers A: This query returns only Martin's orders for July 18, 2000 and July 21, 2002, not orders of others that were placed on the same day that Martin placed his orders. C: This query uses incorrect sub-query to extract dates when Martin placed his orders. D: This query will return only Martin's orders.

Topics

#subquery#date comparison#IN operator#correlated subquery

Community Discussion

7
Hiroshi T.Hiroshi T.May 8, 2026

The answer is B. The key here is that all four options share the same SELECT clause, so the discriminator is always the WHERE clause and subquery structure. Option B correctly uses a correlated or nested subquery to first identify the date or dates on which Martin placed his orders by looking up his customer ID in the CUSTOMERS table, then passes those dates back to the ORDERS table to return every order that falls on those same dates. The Oracle SQL documentation on subqueries, specifically the section covering single-row and multiple-row subqueries with IN, is exactly what you need to review here because Martin could theoretically have more than one order date, which is why IN is safer than the equality operator. Options A, C, and D typically introduce errors such as using a join when a subquery is required, reversing the subquery direction, or applying an equality operator where a set-membership operator belongs, all of which either return wrong rows or produce a too-many-rows error at runtime.

23
Ola B.Ola B.May 25, 2026

The trick here is recognizing that you need a subquery to first pull the order dates tied to Martin from the CUSTOMERS and ORDERS tables, then use those dates in the outer WHERE clause to filter all orders. The options that get this wrong usually try to do it with a simple join or hardcode a date, neither of which works when Martin could have placed orders on multiple days. Answer B is correct because it structures the subquery to look up Martin's ord_date values and feeds them into the outer query with an IN condition, which handles the case of Martin having more than one order date cleanly. Took this exam back when I was prepping hard and hit almost this exact scenario. I almost went with one of the join-only options because I was moving fast, but I caught myself and spun up a quick SQL*Plus session that evening to test the logic before my exam day, and seeing the subquery return the right rows made it click. On the actual test I recognized the pattern immediately and locked in B without second-guessing it.

5
Anjali D.Anjali D.Jun 2, 2026

Group consensus landed on B as well, since the correct approach uses a subquery in the WHERE clause to pull the order dates tied to Martin from the CUSTOMERS join, then matches those dates against the outer query. The key detail everyone agreed on is that the subquery needs to return a set of dates, so the outer query uses IN rather than equals to handle the case where Martin has multiple orders on different days.

2
Ola B.Ola B.Jun 4, 2026

Good call on IN over equals, though I'd spin up a quick lab with a few duplicate-date rows in your test data to see how the engine handles it before assuming that behavior in a real exam scenario.

0
Mateus R.Mateus R.May 1, 2026

B is right, and here is the key reason: the WHERE clause in B uses a subquery to first look up the dates Martin ordered, then feeds those dates back to the outer query, the same way you might ask "what days did Carlos clock in?" before checking who else punched the same time card. That nested lookup is exactly what Oracle SQL needs to match rows across tables without hardcoding a date.

1
Nina C.Nina C.May 20, 2026

B is right, the subquery pulls Martin's order dates for comparison.

0
Ola B.Ola B.May 21, 2026

Yep, and if you spin up a quick sandbox with a few rows of dummy data you will see exactly how the subquery correlates on customer ID, which makes the date comparison behavior a lot more concrete than just reading the syntax.

0
Full 1Z0-007 Practice