SUM and COUNT Quiz

From SQLZOO
Revision as of 11:31, 18 July 2012 by Marek (Talk | contribs)

Jump to: navigation, search

BBC QUIZ

1. Select the statement that shows the sum of population of all countries in 'Europe'

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'

2. Select the statement that shows the number of countries with population smaller than 150000

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

3. Select the full set of SQL aggregate functions

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()

4. Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark'

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')

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

SELECT name, density AS population/area FROM bbc WHERE population = MAX(population)
SELECT name, density AS population/area FROM bbc WHERE population = (SELECT MAX(population) FROM bbc)
SELECT name, MAX (population) FROM bbc WHERE population / (SELECT area 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)

Your score is 0 / 0
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense