0% found this document useful (0 votes)
2 views2 pages

sql4

The document outlines a series of SQL queries to be executed on the 'World' database, covering various tasks such as displaying country data, filtering by continent and population, and aggregating information about languages and independence years. It includes instructions for adding a new country and manipulating its data. Additionally, it prompts the user to explore the consequences of deleting the newly added country.

Uploaded by

ahmed hussein
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

sql4

The document outlines a series of SQL queries to be executed on the 'World' database, covering various tasks such as displaying country data, filtering by continent and population, and aggregating information about languages and independence years. It includes instructions for adding a new country and manipulating its data. Additionally, it prompts the user to explore the consequences of deleting the newly added country.

Uploaded by

ahmed hussein
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL problems – Part1

Using “World” database, do the following:


1- Display all data for all the countries.
select * from Country

2- Display all the languages you have. (Remove redundant data) (457 rows)
select distinct Language
from CountryLanguage

3- Display all countries that lie in Africa sorted by Area. (58 rows)
select *
from Country
where Continent = 'Africa'
order by surfacearea

4- Display all cities that have population more than 2 million. (92 rows)
select *
from City
where [population] > 2000000

5- Display all countries that became independent from 1920 t0 1990. (108 rows)
select *
from Country
where indepyear between 1920 and 1990

6- Display all countries that have no independence year. (47 rows)


select *
from Country
where indepyear is null

7- Display all countries that have any kind of ‘Republic’ government form. (143
rows) select *
from Country
where governmentform like '%Republic%'
8- Display all countries that lie in Asia and have population more than 100 million.
(6 rows)
select *
from Country
where continent = 'Asia' and [population] > 100000000

9- Display country code for all those speak Spanish as an official language. (20
rows)
select countrycode
from CountryLanguage
where [Language] = 'Spanish' and isofficial = 'true'

10- Display country code for all those speak more than 2 languages. (149 rows)
select countrycode
from CountryLanguage
group by countrycode
having count(*) > 2

11- Display the number of people on earth.


select sum([population])
from Country

12- Display all Continents along with the number of countries and total
population in each continent. (7 rows)
select Continent, count(*), sum([population])
from Country
group by Continent

13- You have just discovered a new country, Add it to your database. (Of course,
your country have some cities and languages)
14- In your country, increase life expectation by 5 years.
15- Try to delete your country, what happens?

You might also like