I have one table called customer (cust_id,name,address,city). I want to write a query for this table to list the city name that has got the maximum number of customers and also to list the number of customers. Can you help me out?

    Requires Free Membership to View

select city, count(cust_id)
  from customer
        group by city
        having count(cust_id) = (select max(count(city))
      from customer
                                 group by city)
 

This was first published in October 2004

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.