This may look odd, but it should work as-is, on MySQL 5.0 or greater:If you're using custom table prefixes, you'll need to add your prefix to the two highlighted tablenames.Code:SET @custcount=0; SELECT (@custcount:=count(*)) as custcount FROM customers; SELECT numorders, count(numorders) as numcusts, @custcount as totalcustomers, count(numorders)/@custcount as percent FROM (SELECT count(orders_id) AS numorders FROM orders GROUP BY customers_id) o GROUP BY (o.numorders) ORDER BY numorders DESC;



