In the following query of current/perspective customers, I need to display, CustomerID, Customer's LastName, along with a column that displays whether customer has placed at least
one order or not.
But, as expected, it displays multiple records of a customer if the customer placed multiple orders (one-to-many relationship). Question: How can we display only one record per customer here since we need only to report whether or not a customer has placed at least one order?
SELECT c.customerID, o.OrderID, CASE When ISNULL(o.OrderID, 0) = 0 Then 0 Else
1 End as YesNO
FROM Customers c
LEFT JOIN Orders o
ON c.customerID = o.customerID