I have the following simple table:

CustomerID  CustomerName   NumOfOrders
1           Joe            15
2           Jane           20
7           Clara          1

I want to find the customer with maximum number of orders. Seems trivial enough but I can,t seem to find a solution.

hello can i intercept this thread?

which is faster select max(NumOfOrders) from table

or

select NumOfOrders from table order by NumOfOrders desc limit 1

Why don't you profile that query, I think it depends on whether you're using the right index.

Select Top 1 CustomerID,CustomerName, NumOfOrders from Table order by NumOfOrders desc
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.