Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL: Using the sqlzoo.net World table: Create queries to do the following: 1) Di

ID: 3890959 • Letter: S

Question

SQL:

Using the sqlzoo.net World table:

Create queries to do the following:

1) Display the countries in Asia and their per capita gdp, ordered by the per capita gdp with the largest first.

use rounding to display no more than 2 digits

2) List the number of countries in each continent whose per capita gdp is greater than 20,000

Using the "More Joins operations" page on the sqlzoo.net site and the movie, actor, and casting tables described on that page:

3) List the actors in the movie "Forrest Gump"

4) List the movies in which the actor Tom Hanks has appeared

Explanation / Answer

1) Display the countries in Asia and their per capita gdp, ordered by the per capita gdp with the largest first.

use rounding to display no more than 2 digits

Answer :

SELECT name , ROUND (gdp /population , 2 ) FROM world
WHERE continent = 'Asia'
order by (gdp /population ) desc ;

2.) List the number of countries in each continent whose per capita gdp is greater than 20,000

Answer :

SELECT continent , count(name )
FROM world
WHERE (gdp /population ) > 20000
group by continent ;

3.) List the actors in the movie "Forrest Gump"

Answer :

SELECT name
FROM movie JOIN actor
where movie.id = actor.id ;

4 ) List the movies in which the actor Tom Hanks has appeared

. Answer

SELECT title

FROM movie JOIN actor
where movie.id = actor.id and actor.name = 'Tom Hanks';