CrazyEngineers
  • Can you solve this sql query?

    Manish Goyal

    Manish Goyal

    @manish-r2Hoep
    Updated: Oct 21, 2024
    Views: 1.1K
    Say i have 4 tables

    each table have two common attribute say name of city and population

    I want to retrieve name of city with minimum population

    can you find it?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • blak

    MemberMar 20, 2011

    select city_name,min(population) pop
    from
    (
    select city_name, population from table1
    union
    select city_name, population from table2
    union
    select city_name, population from table3
    union
    select city_name, population from table4
    )
    group by city_name
    order by pop;
    Are you sure? This action cannot be undone.
    Cancel
  • ISHAN TOPRE

    MemberMar 20, 2011

    select city_name,
    from table1, table2, table3, table4,
    where population<= P1, P2, P3, P4.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register