Make an inner join. It is much easier and more readable.
select customerName, customerID, count(*) as numberTransactions from customerdata c inner join purchases p on c.customerID = p.customerID group by customerName,customerID order by numberTransactions
EDIT: Hey Nathan,
Do you understand that you can combine this whole table as a right on the right?
Select T.*, T2.* From T inner join (select customerName, customerID, count(*) as numberTransactions from customerdata c inner join purchases p on c.customerID = p.customerID group by customerName,customerID ) T2 on T.CustomerID = T2.CustomerID order by T2.numberTransactions
Or, if this is not good, you can create your queries using temporary tables (# T1, etc.)
Jason punyon
source share