select customer.customerId,customer.customerName,count(orders.orderId) as orderCount from customer inner join orders on customer.customerId=orders.customerId group by customer.customerId,customer.customerName order by orderCount desc
调试欢乐多
-------------------------
是不是想按order表中每个customer对应的order的数量排序?select c.*,count(o.orderId) as oc
from customer c, orders o
where c.customerId=o.customerId
group by o.customerId
order by oc