Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: MAX and min

  1. #1
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MAX and min

    I have a table called country which has a field called life expectancy I need to ran a query to bring up the names of countrys with both max life expectancy and min life expectancy in one run. I have manged to do this seperately but need help with the single query.


    JUST MAX

    select continent "Continent",
    MAX(LifeExpectancy) "Life Expectancy"
    from country
    Group by continent asc limit 0,1;

    JUST MIN

    select continent "Continent",
    MIN(LifeExpectancy) "Life Expectancy"
    from country
    Group by continent desc limit 0,1;

    any help will be great

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    put UNION in the middle of the queries and use that


  •  

    Posting Permissions

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