Results 1 to 3 of 3

Thread: Nested Select

  1. #1
    Join Date
    Jan 2012
    Posts
    52

    Unanswered: Nested Select

    Hi,

    I am doing some excercises about nested selects but cannot figure out what is the problem.
    There is a table that has name, continent, area, population, gdp and the question is:
    Which country has a population that is more than Canada but less than Poland? Show the name and the population

    I have come with the following but is not working, can someone help me out please?

    Thanks!

    Code:
    SELECT name, population FROM world where name in
    (SELECT population FROM world
            WHERE population > 'Canada' and population < 'Poland')

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    What you need to do is to find the population of Poland and Canada.

    Code:
    SELECT name, w.population 
    FROM world w
    WHERE population > (SELECT population FROM world WHERE name = 'Canada')
    AND population < (SELECT population FROM world  WHERE name = 'Poland');
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Jan 2012
    Posts
    52
    Thanks for the help. Figured out how to fix it, and is exactly the same as your code. I highly appreciate your time and help

Posting Permissions

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