Hacker Rank SQL

Population Census Solution

Hello Friends in this article i am gone to share Hacker Rank SQL Solutions with you | Population Census Solution


Also Visit:  Weather Observation Station 20 Solution


 

Problem

Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is ‘Asia’.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

Input Format

The CITY and COUNTRY tables are described as follows:

Field Type
ID NUMBER
NAME VARCHAR2(17)
COUNTRYCODE VARCHAR2(3)
DISTRICT VARCHAR2(20)
POPULATION NUMBER
Field Type
CODE VARCHAR2(3)
NAME VARCHAR2(44)
CONTINENT VARCHAR2(13)
REGION VARCHAR2(25)
SURFACEAREA NUMBER
INDEPYEAR VARCHAR2(5)
POPULATION NUMBER
LIFEEXPECTANCY VARCHAR2(4)
GNP NUMBER
GNPOLD VARCHAR2(9)
LOCALNAME VARCHAR2(44)
GOVERNMENTFORM VARCHAR2(44)
HEADOFSTATE VARCHAR2(32)
CAPITAL VARCHAR2(4)
CODE2 VARCHAR2(2)

Solution – Population Census

MySQL Code
select sum(city.population) from country 
left join city on country.code = city.countrycode where 
country.continent = 'Asia'

 


A population census is an enumeration of people, houses, firms, or other important items in a country or region at a particular time. It is used to collect demographic, economic, and social data pertaining to a specific time for all persons in a country or fixed or defined area part of a country¹.

The modern idea of a population census as a complete enumeration of all the people and their important characteristics for purposes of understanding the basic structure and trends of the society rather than for identifying and controlling particular individuals slowly arose in the 17th and 18th centuries.

I hope this helps! Let me know if you have any other questions.

 

 

Disclaimer: The above Problems are generated by Hacker Rank but the Solutions are Provided by NYANDER.COM. All Hacker Rank SQL Solutions Shared only for Educational and Learning Purpose.