QuestionQ240

VerifiedData Processing & Transformations

A data engineer needs to identify all customers who have never placed an order. The customers table includes customer_id, customer_name, and other customer attributes. The orders table includes order_id, customer_id, and other order attributes. Both tables are joined on customer_id. The output must contain only customer columns — no order-related columns.

Which expression precisely satisfies this requirement?

Explanation

A left anti-join returns only the rows from the left table (customers) that have no corresponding match in the right table (orders), and it inherently returns only the columns of the left table — never including any columns from the right table. This directly satisfies the requirement of returning customers with no orders and excluding order-related columns, without requiring any additional filtering step. In contrast, an inner join can never produce NULL keys, a left/full outer join would include order columns (such as order_id) in the joined result requiring extra filtering and column selection, and joining from orders to customers reverses the intended relationship, since orders with no customers is not the question being asked.

Community Discussion

No comments yet. Be the first to start the discussion!