Can you solve this sql query?

Manish Goyal

Manish Goyal

@manish-r2Hoep Oct 21, 2024
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?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • blak

    blak

    @blak-xvIZ0J Mar 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;
  • ISHAN TOPRE

    ISHAN TOPRE

    @ishan-nohePN Mar 20, 2011

    select city_name,
    from table1, table2, table3, table4,
    where population<= P1, P2, P3, P4.