1. Continent_summary_view : SQL: Create a view to display each continent name, t
ID: 3721407 • Letter: 1
Question
1. Continent_summary_view:
SQL: Create a view to display each continent name, the number of countries in the continent, the total surface areas, and the total populations.
2. Population_view:
SQL: Create a view to display each country name, country populations, the largest city populations of the country. Only North and South America countries are listed.
MySQL5.5 Command Line Client t Code l charK3> NO PRI Name l char NO tRegiorn enun'Asia''Europe'North Anerica''frica' '0ceania.'Anta t Asia i char(26 l float char(45) char 45 NULL NULL NULL t GovernmentForm ich(6D) l int 11) i char 2 HeadOf State YES YES NO NULL Capital NULL tCode2 15 rows in set (0.02 sec mysql> describe city Field Type iNull Key Default Extra int(11) NO I PRI I NULL I auto-incre nent t Name tCountryCodechar3 NO District t char(20 NO Population int 11> NO 5 rows in set .02 sec> mysql describe countrylanguage; : Field i CountryCode char3) t Type Null Key Default Extra NO PRI I NOPRI anguage t char i Percentage float (3.1> NO 0.0Explanation / Answer
Answer:
1. Continent_summary_view:
CREATE VIEW Continent_summary_view AS
SELECT a.Name,
a.SurfaceArea,
a.Population,
SUM(b.countryCode)
FROM continent_summary a ,
city b
GROUP BY a.Name,
a.SurfaceArea,
a.Population;
2. Population_view:
CREATE VIEW Population_view AS
SELECT a.name,
a.population,
(SELECT MAX(c.population)
FROM city c,
continent c1
WHERE c1.code = c.countryCode
)
FROM Continent_summary a;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.