Reputation: 11
I am new to sql and and have looked at many examples but have no idea how to make my query work. I ran the following query:
select name, (select population/area) as density from country
which listed all my country's and their population density (which was population divided by area). However I want to run a query on the results that I got here to give me just one row that will return the country with the MAX density. Is this possible, if so can you tell me how as everything I try and do just wont work?
Thanks for any help!
Terry
Upvotes: 1
Views: 51
Reputation: 11893
Try this:
select top 1 name, (select population/area) as density from country
order by 2
Upvotes: 1