ALL, DISTINCT, DISTINCTROW, TOP Predicates Example

This example creates a query that joins the Customers and Orders tables on the CustomerID field. The Customers table contains no duplicate CustomerID fields, but the Orders table does because each customer can have many orders. Using DISTINCTROW produces a list of companies that have at least one order but without any details about those orders.

SELECT DISTINCTROW CompanyName 
FROM Customers INNER JOIN Orders 
ON Customers.CustomerID = Orders.CustomerID 
ORDER BY CompanyName;