Customers - Repeat Customers
SELECT
CUSTOMERS.CUSTOMERID as [CustomerID],
CUSTOMERS.FirstName,
CUSTOMERS.SurName,
Customers.EmailAddress,
COUNT(ORDERS.CUSTOMERID) AS [Orders]
FROM
ORDERS
INNER JOIN
CUSTOMERS
ON CUSTOMERS.CUSTOMERID=ORDERS.CUSTOMERID
GROUP BY
ORDERS.CUSTOMERID,
CUSTOMERS.CUSTOMERID,
CUSTOMERS.FirstName,
CUSTOMERS.SurName,
Customers.EmailAddress
ORDER BY
COUNT(ORDERS.CUSTOMERID) DESC