View Single Post
  #2 (permalink)  
Old 05-24-2006, 12:03 AM
alexfr alexfr is offline
Junior Member
 
Join Date: May 2006
Posts: 24
alexfr is on a distinguished road
Default SQL 92 answer. Re: List by ascending number of orders the customers that have placed more than 1 order?

[sql]SELECT c.id, c.firstname, c.lastname, COUNT(o.order_id) as total
FROM customers c INNER JOIN orders o ON c.customer_id = c.customer_id
GROUP BY c.customer_id, c.lastname
HAVING COUNT(o.order_id) > 1
ORDER BY COUNT(o.order_id) ASC[/sql]
Reply With Quote