Difference between revisions of "SUM and COUNT Quiz"

From SQLZOO
Jump to: navigation, search
Line 33: Line 33:
 
- SELECT population FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')
 
- SELECT population FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')
  
{Select all the statements that show all the countries in 'Africa'
+
{Select the statement that shows the name and population density of the country with the largest population
 +
<div class="hint" title="Population density">Population density is population/area.</div>
 
|type="()"}
 
|type="()"}
- SHOW country WHERE region = 'Africa'
+
+ SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)
- SELECT country WHERE region LIKE 'Africa'
+
- SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)
+ SELECT name FROM bbc WHERE region LIKE 'Africa'
+
- SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)
+ SELECT name FROM bbc WHERE region = 'Africa'
+
- SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)
- SELECT region = 'Africa' FROM bbc
+
- SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)
 
</quiz>
 
</quiz>
  
 
[[Category:Quizzes]]
 
[[Category:Quizzes]]

Revision as of 11:25, 18 July 2012

BBC QUIZ <quiz shuffle=none display=simple> {Select the statement that shows the sum of population of all countries in 'Europe' |type="()"} - SELECT name, population FROM bbc WHERE region = 'Europe' - SELECT population FROM bbc WHERE region = 'Europe' SUM BY region + SELECT SUM(population) FROM bbc WHERE region = 'Europe' - SELECT SUM(population FROM bbc WHERE region = 'Europe') - SUM population FROM bbc WHERE region = 'Europe'

{Select the statement that shows the number of countries with population smaller than 150000 |type="()"} + SELECT COUNT(name) FROM bbc WHERE population < 150000 - SELECT COUNT(population < 150000) FROM bbc - SELECT name FROM bbc WHERE population < 150000 - SELECT population AS COUNT FROM bbc WHERE population < 150000 - SELECT SUM() FROM bbc WHERE population < 150000

{Select the full set of SQL aggregate functions |type="()"} - AVG(), COUNT(), FIRST(), LAST(), SUM() - AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM() + AVG(), COUNT(), FIRST(), LAST(), MAX(), MIN(), SUM() - AVG(), COUNT(), MAX(), MIN(), SUM() - COUNT(), SUM()

{Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark' |type="()"} - SELECT AVG(population) FROM bbc WHERE name = ('Poland', 'Germany', 'Denmark') + SELECT AVG(population) FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark') - SELECT AVG(population) FROM bbc WHERE name LIKE ('Poland', 'Germany', 'Denmark') - SELECT AVG(population) FROM bbc WHERE name LIKE (Poland, Germany, Denmark) - SELECT population FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')

{Select the statement that shows the name and population density of the country with the largest population

Population density is population/area.

|type="()"} + SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) - SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) - SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) - SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) - SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) </quiz>