# SQLZoo Quiz Answers Key 2023 [FREE ACCESS]

Do you need help finding the answers to the quiz on their SQLZoo website? Check out these handy SQLZoo quiz answers which we shared below for free:

NOTE: All quiz answers to SQLZoo are checked twice before publishing them to you. So, please do share as well if it helps you.

## SQLZoo Answers – Solution to All Levels of Quiz Questions

We have revealed the answers to all the SQLZoo Quizzes below:

Note: If anything is missing/alter or to be removed please let us know through the comment box in the bottom of this page.

Check the quiz answers for the topic “SELECT” below:

Q. Select the code which produces this table:

Ans:
SELECT name, population
FROM world
WHERE population BETWEEN 1000000 AND 1250000

Q. Pick the result you would obtain from this code:
SELECT name, population
FROM world
WHERE name LIKE “Al%”
Ans: Table E

Q. Select the code which shows the countries that end in A or L
Ans:
SELECT name FROM world
WHERE name LIKE ‘%a’ OR name LIKE ‘%l’

Q. Pick the result from the query
SELECT name,length(name)
FROM world
WHERE length(name)=5 and region=’Europe’
Ans:

Q. Here are the first few rows of the world table:

Pick the result you would obtain from this code:
Ans:

Q. Select the code that would show the countries with an area larger than 50000 and a population smaller than 10000000
Ans:
SELECT name, area, population
FROM world
WHERE area > 50000 AND population < 10000000

Q. Select the code that shows the population density of China, Australia, Nigeria, and France
Ans:
SELECT name, population/area
FROM world
WHERE name IN (‘China’, ‘Nigeria’, ‘France’, ‘Australia’)

### SUM and COUNT Quiz Answers

Check the quiz answers for the topic “SUM and COUNT” below:

Q. Select the statement that shows the sum of population of all countries in ‘Europe’
Ans: SELECT SUM(population) FROM bbc WHERE region = ‘Europe’

Q. Select the statement that shows the number of countries with population smaller than 150000
Ans: SELECT COUNT(name) FROM bbc WHERE population < 150000

Q. Select the list of core SQL aggregate functions
Ans: AVG(), COUNT(), MAX(), MIN(), SUM()

Q. Select the result that would be obtained from the following code:
SELECT region, SUM(area)
FROM bbc
WHERE SUM(area) > 15000000
GROUP BY region
Ans: No result due to invalid use of the WHERE function

Q. Select the statement that shows the average population of ‘Poland’, ‘Germany’ and ‘Denmark’
Ans: SELECT AVG(population) FROM bbc WHERE name IN (‘Poland’, ‘Germany’, ‘Denmark’)

Q. Select the statement that shows the medium population density of each region
Ans: SELECT region, SUM(population)/SUM(area) AS density FROM bbc GROUP BY region

Q. Select the statement that shows the name and population density of the country with the largest population
Ans: SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)

Q. Pick the result that would be obtained from the following code:
SELECT region, SUM(area)
FROM bbc
GROUP BY region
HAVING SUM(area)<= 20000000
Ans: Table-D

Check the quiz answers for the topic “Self Join” below:

Q. Select the code that would show it is possible to get from Craiglockhart to Haymarket
Ans:
SELECT DISTINCT a.name, b.name
FROM stops a JOIN route z ON a.id=z.stop
JOIN route y ON y.num = z.num
JOIN stops b ON y.stop=b.id
WHERE a.name=’Craiglockhart’ AND b.name =’Haymarket’

Q. Select the code that shows the stops that are on route.num ‘2A’ which can be reached with one bus from Haymarket?
Ans:
SELECT S2.id, S2.name, R2.company, R2.num
FROM stops S1, stops S2, route R1, route R2
WHERE S1.name=’Haymarket’ AND S1.id=R1.stop
AND R1.company=R2.company AND R1.num=R2.num
AND R2.stop=S2.id AND R2.num=’2A’

Q. Select the code that shows the services available from Tollcross?
Ans:
SELECT a.company, a.num, stopa.name, stopb.name
FROM route a JOIN route b ON (a.company=b.company AND a.num=b.num)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
WHERE stopa.name=’Tollcross’

Check the quiz answers for the topic “BBC Quiz” below:

Q. Select the code which gives the name of countries beginning with U
Ans:
SELECT name
FROM world
WHERE name LIKE ‘U%’

Q. Select the code which shows just the population of United Kingdom?
Ans:
SELECT population
FROM world
WHERE name = ‘United Kingdom’

Q. Select the answer which shows the problem with this SQL code – the intended result should be the continent of France:
SELECT continent
FROM world
WHERE ‘name’ = ‘France’
Ans: ‘name’ should be name

Q. Select the result that would be obtained from the following code:
SELECT name, population / 10
FROM world
WHERE population < 10000
Ans: Nauru 990

Q. Select the code which would reveal the name and population of countries in Europe and Asia
Ans:
SELECT name, population
FROM world
WHERE continent IN (‘Europe’, ‘Asia’)

Q. Select the code which would give two rows
Ans:
SELECT name FROM world
WHERE name IN (‘Cuba’, ‘Togo’)

Q. Select the result that would be obtained from this code:
SELECT name FROM world
WHERE continent = ‘South America’
AND population > 40000000
Ans:

Check the quiz answers for the topic “Noble Quiz” below:

Q. Pick the code which shows the name of winner’s names beginning with C and ending in n
Ans:
SELECT winner FROM nobel
WHERE winner LIKE ‘C%’ AND winner LIKE ‘%n’

Q. Select the code that shows how many Chemistry awards were given between 1950 and 1960
Ans:
SELECT COUNT(subject) FROM nobel
WHERE subject = ‘Chemistry’
AND yr BETWEEN 1950 and 1960

Q. Pick the code that shows the amount of years where no Medicine awards were given
Ans:
SELECT COUNT(DISTINCT yr) FROM nobel
WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = ‘Medicine’)

Q. Select the result that would be obtained from the following code:
SELECT subject, winner FROM nobel WHERE winner LIKE ‘Sir%’ AND yr LIKE ‘196%’
Ans:

Q. Select the code which would show the year when neither a Physics or Chemistry award was given
Ans:
SELECT yr FROM nobel
WHERE yr NOT IN(SELECT yr
FROM nobel
WHERE subject IN (‘Chemistry’,’Physics’))

Q. Select the code which shows the years when a Medicine award was given but no Peace or Literature award was
Ans:
SELECT DISTINCT yr
FROM nobel
WHERE subject=’Medicine’
AND yr NOT IN(SELECT yr FROM nobel
WHERE subject=’Literature’)
AND yr NOT IN (SELECT yr FROM nobel
WHERE subject=’Peace’)

Q. Pick the result that would be obtained from the following code:
SELECT subject, COUNT(subject)
FROM nobel
WHERE yr =’1960′
GROUP BY subject
Ans:

Check the quiz answers for the topic “Nested SELECT” below:

Q. Select the code that shows the name, region and population of the smallest country in each region
Ans: SELECT region, name, population FROM bbc x WHERE population <= ALL (SELECT population FROM bbc y WHERE y.region=x.region AND population>0)

Q. Select the code that shows the countries belonging to regions with all populations over 50000
Ans: SELECT name,region,population FROM bbc x WHERE 50000 < ALL (SELECT population FROM bbc y WHERE x.region=y.region AND y.population>0)

Q. Select the code that shows the countries with a less than a third of the population of the countries around it
Ans:
SELECT name, region FROM bbc x
WHERE population < ALL (SELECT population/3 FROM bbc y WHERE y.region = x.region AND y.name != x.name)

Q. Select the result that would be obtained from the following code:
SELECT name FROM BBC
WHERE population >
(SELECT population
FROM BBC
WHERE name=’United Kingdom’)
AND region IN
(SELECT region
FROM BBC
WHERE name = ‘United Kingdom’)
Ans: Table D

Q. Select the code that would show the countries with a greater GDP than any country in Africa (some countries may have NULL gdp values).
Ans:
SELECT name FROM BBC
WHERE gdp > (SELECT MAX(gdp) FROM bbc WHERE region = ‘Africa’)

Q. Select the code that shows the countries with population smaller than Russia but bigger than Denmark
Ans:
SELECT name FROM BBC
WHERE population < (SELECT population FROM bbc WHERE name=’Russia’) AND population > (SELECT population FROM BBC WHERE name=’Denmark’)

Q. >Select the result that would be obtained from the following code:
SELECT name FROM bbc
WHERE population > ALL
(SELECT MAX(population)
FROM bbc
WHERE region = ‘Europe’)
AND region = ‘South Asia’
Ans: Table B

Check the quiz answers for the topic “Using Null” below:

Q. Select the code which uses an outer join correctly.
Ans: SELECT teacher.name, dept.name FROM teacher LEFT OUTER JOIN dept ON (teacher.dept = dept.id)

Q. Select the correct statement that shows the name of department which employs Cutflower –
Ans: SELECT dept.name FROM teacher JOIN dept ON (dept.id = teacher.dept) WHERE teacher.name = ‘Cutflower’

Q. Select out of following the code which uses a JOIN to show a list of all the departments and number of employed teachers
Ans: SELECT dept.name, COUNT(teacher.name) FROM teacher RIGHT JOIN dept ON dept.id = teacher.dept GROUP BY dept.name

Q. Using SELECT name, dept, COALESCE(dept, 0) AS result FROM teacher on teacher table will:
Ans: display 0 in result column for all teachers without department

Q. Query:
SELECT name,
CASE WHEN phone = 2752 THEN ‘two’
WHEN phone = 2753 THEN ‘three’
WHEN phone = 2754 THEN ‘four’
END AS digit
FROM teacher
shows following ‘digit’:
Ans: ‘four’ for Throd

Q. Select the result that would be obtained from the following code:
SELECT name,
CASE
WHEN dept
IN (1)
THEN ‘Computing’
ELSE ‘Other’
END
FROM teacher
Ans: Table-A

SQLZoo is a site that offers free SQL tutorials. The tutorials are brief and to the point, making them perfect for busy people who want to learn SQL without commitment.

Each tutorial has a set of questions to test your understanding. SQLZoo is an excellent resource for those who want to learn SQL.

If you’re looking for a quick and easy way to learn SQL, look no further than SQLZoo.

We hope you find all the required SQLZoo Quiz Answers key from above.

If it helped make sure you shared it with your friends who might be looking for the same.