What Is The Old Name Of Lahore City?

SQL: How do I select the name of the oldest person in a city for each city?

  • How do I select the name of the oldest person in a city for each city? Imagine a table with the schema census {name, age, city}. I want to select the name and age of the oldest person in each city. I have tried: SELECT name, max(age) FROM census group by city but I am not sure it's returning the right data.

  • Answer:

    Looks right to me. Make sure the age column is a number or integer and *not* a varchar. Sorting integers as strings gets funky. For example 100 comes before 11.

eagle5co... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

The Bureau never divulges information where a particular individual has a remote chance of being identified. The Bureau can determine the age of the oldest person in a particular city, but if they tell you, somebody is probably going to jail.

Your query is not correct. select c.city, c.name, max_age from census c join ( select city, max(age) max_age from census) x on c.city=x.city and max_age=c.age

Looks right to me too... why do you think that it's wrong? Try: SELECT name, max(age) FROM census ORDER BY max(age)

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.