shilps
shilps

Reputation:

query in sql database

How do we find the top 2 most populated cities i.e where no. of customers are higher than any other

Upvotes: 3

Views: 84

Answers (1)

Ian Henry
Ian Henry

Reputation: 22403

Assuming your schema looks like:

Customers
  -City
  -SSN

You should be able to simply use limit:

select City, count(SSN)
from Customers
group by City
order by count(SSN) desc
limit 2

Upvotes: 3

Related Questions