
Explanation:
Correct Answer: D: LEFT OUTER JOIN
The requirement is to get all customers (including those who have never placed an order), along with their order details when they exist.
This is a classic "all records from left table + matching records from right table" scenario.
SELECT
c.*,
o.*
FROM customers c
LEFT OUTER JOIN orders o
ON c.customer_id = o.order_customer_id
SELECT
c.*,
o.*
FROM customers c
LEFT OUTER JOIN orders o
ON c.customer_id = o.order_customer_id
customers are returned.NULL.| Option | Join Type | Result | Why Incorrect? |
|---|---|---|---|
| A | RIGHT OUTER JOIN | All orders + matching customers | Misses customers who have no orders |
| B | INNER JOIN | Only customers who have placed at least one order | Excludes customers with no orders |
| C | FULL OUTER JOIN | All customers + all orders (including orphan orders) | Returns extra rows (orders without customers) and is less efficient |
| E | Either LEFT or RIGHT | Technically possible if you swap table order | Misleading. While you can achieve it with RIGHT JOIN by reversing tables, the natural and expected way (given customers is mentioned first) is LEFT JOIN. |
Note: Option E is a common trap in certification exams. While semantically equivalent if you rewrite the query, the standard and most readable solution is LEFT OUTER JOIN when you want all records from the primary (left) table.
This concept is heavily tested in the Databricks Data Engineer Associate exam under Lakehouse and SQL sections.
Ultimate access to all questions.
A data engineer needs to join two tables, customers and orders, on the condition c.customer_id = o.order_customer_id. The goal is to retrieve details of all customers, including those who have not placed any orders, along with the details of orders they have placed. Given the schemas of both tables, which join operation should be used to achieve this?
A
RIGHT OUTER JOIN
B
INNER JOIN
C
FULL OUTER JOIN
D
LEFT OUTER JOIN
E
Either LEFT OUTER JOIN or RIGHT OUTER JOIN can be used