Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2013
    Posts
    10

    Unanswered: How list the country with the greatest population

    We have a table that has 2 attributes (Name, population)
    When I write:

    SELECT Name, MAX (Population) From Country

    I don’t see the name of “correct” country in the result.
    Suppose the correct answer is “China”
    But I see the “Austria” (the first name in the table) instead of seeing “China”

    Could you please guide me

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Please try...
    Code:
    ...
     ORDER BY
           population DESC
     LIMIT 1

  3. #3
    Join Date
    Feb 2013
    Posts
    10

    MAX In MYSQL

    I try following code:

    SELECT Name, MAX (Population) From Country
    ORDER BY population DESC
    LIMIT 1;

    But it doesn't work !
    Last edited by OmidUOL; 02-17-13 at 06:57.

  4. #4
    Join Date
    Feb 2013
    Posts
    10

    MAX In MYSQL

    I try following code:

    SELECT Name, MAX (Population) From Country
    ORDER BY population DESC
    LIMIT 1;

    But it doesn't work !

  5. #5
    Join Date
    Feb 2013
    Posts
    10
    I'm so SORRY I sent it double by mistake..

    Oh I should delete the "MAX" .. Thank you it works
    Is there other way that using "MAX" and receive correct result?
    Last edited by OmidUOL; 02-17-13 at 07:06.

  6. #6
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Quote Originally Posted by OmidUOL View Post
    ...
    Is there other way that using "MAX" and receive correct result?
    Why do you insist on using MAX function?
    I have an idea, but it makes query complex.
    I don't know other simpler way using MAX function, now.

  7. #7
    Join Date
    Feb 2013
    Posts
    10
    Quote Originally Posted by tonkuma View Post
    Why do you insist on using MAX function?
    I have an idea, but it makes query complex.
    I don't know other simpler way using MAX function, now.
    Thank you it's enough

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •