Question:
Can someone help me with writing these SQL queries?
LINDA
2013-10-05 14:04:16 UTC
1. List the average, minimum, and maximum population of all countries with a non-zero population in the database
2. List the total population, surface area and GNP by continent; order the results from smallest to largest surface area.
3. Generate a list of all forms of government with the count of how many countries have that form of government. Also, list the most recent year in which any country became independent with that form of government. The results should be ordered by the independence year field in decreasing order. (Note: Some countries may have NULL for the independence year. Those countries should not be considered when finding the earliest independence year.)
4. For each country that contains a city, list the total number of cities it contains. Order the results in descending order of the number of cities.
5. List the country name, it’s population, and the sum of the populations of all cities in that country. Add a fourth field to your query that calculates the percent of urban population for each country. (For the purposes of this example, assume that the sum of the populations of all cities listed for a country represent that country’s entire urban population.) Order the results of this query in decreasing order of urban population percentage.
6. For each country, list the largest population of any of its cities and the name of that city. Order the results alphabetically by country.
7. List the countries in ascending order beginning with the country with the smallest number of cities in the database and ending with the country with the largest number of cities in the database. Cities that have the same number of cities should be sorted alphabetically from A to Z.
8. For each country with 5-10 languages, list the number of languages spoken, in descending order by number of languages as well as the name of the capital for that country.


There are 3 tables in the schema. city, country and country_language
Three answers:
Rick
2013-10-05 14:49:12 UTC
Telling us the columns in each table would be most helpful.
Jeff P
2013-10-06 01:50:13 UTC
Not going to do your homework for you.
Serge M
2013-10-06 15:59:57 UTC
You can teach yourself at http://sql-ex.com


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...