Difference between revisions of "SUM and COUNT Quiz"

From SQLZOO
Jump to: navigation, search
Line 3: Line 3:
 
{Select the statement that shows the sum of population of all countries in 'Europe'
 
{Select the statement that shows the sum of population of all countries in 'Europe'
 
|type="()"}
 
|type="()"}
- SELECT name, population FROM bbc WHERE region = 'Europe'
+
-A. SELECT name, population FROM bbc WHERE region = 'Europe'
- SELECT population FROM bbc WHERE region = 'Europe' SUM BY region
+
-B. SELECT population FROM bbc WHERE region = 'Europe' SUM BY region
+ SELECT SUM(population) FROM bbc WHERE region = 'Europe'
+
+C. SELECT SUM(population) FROM bbc WHERE region = 'Europe'
- SELECT SUM(population FROM bbc WHERE region = 'Europe')
+
-D. SELECT SUM(population FROM bbc WHERE region = 'Europe')
- SUM population FROM bbc WHERE region = 'Europe'
+
-E. SUM population FROM bbc WHERE region = 'Europe'
  
 
{Select the statement that shows the number of countries with population smaller than 150000
 
{Select the statement that shows the number of countries with population smaller than 150000
 
|type="()"}
 
|type="()"}
+ SELECT COUNT(name) FROM bbc WHERE population < 150000
+
+A. SELECT COUNT(name) FROM bbc WHERE population < 150000
- SELECT COUNT(population < 150000) FROM bbc
+
-B. SELECT COUNT(population < 150000) FROM bbc
- SELECT name FROM bbc WHERE population < 150000
+
-C. SELECT name FROM bbc WHERE population < 150000
- SELECT population AS COUNT FROM bbc WHERE population < 150000
+
-D. SELECT population AS COUNT FROM bbc WHERE population < 150000
- SELECT SUM() FROM bbc WHERE population < 150000
+
-E. SELECT SUM() FROM bbc WHERE population < 150000
  
 
{Select the full set of SQL aggregate functions
 
{Select the full set of SQL aggregate functions
 
|type="()"}
 
|type="()"}
- AVG(), COUNT(), FIRST(), LAST(), SUM()
+
-A. AVG(), COUNT(), FIRST(), LAST(), SUM()
- AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM()
+
-B. AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM()
+ AVG(), COUNT(), FIRST(), LAST(), MAX(), MIN(), SUM()
+
+C. AVG(), COUNT(), FIRST(), LAST(), MAX(), MIN(), SUM()
- AVG(), COUNT(), MAX(), MIN(), SUM()
+
-D. AVG(), COUNT(), MAX(), MIN(), SUM()
- COUNT(), SUM()
+
-E. COUNT(), SUM()
  
 
{Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark'
 
{Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark'
 
|type="()"}
 
|type="()"}
- SELECT AVG(population) FROM bbc WHERE name = ('Poland', 'Germany', 'Denmark')
+
-A. SELECT AVG(population) FROM bbc WHERE name = ('Poland', 'Germany', 'Denmark')
+ SELECT AVG(population) FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')
+
+B. SELECT AVG(population) FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')
- SELECT AVG(population) FROM bbc WHERE name LIKE ('Poland', 'Germany', 'Denmark')
+
-C. SELECT AVG(population) FROM bbc WHERE name LIKE ('Poland', 'Germany', 'Denmark')
- SELECT AVG(population) FROM bbc WHERE name LIKE (Poland, Germany, Denmark)
+
-D. SELECT AVG(population) FROM bbc WHERE name LIKE (Poland, Germany, Denmark)
- SELECT population FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')
+
-E. SELECT population FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark')
  
 
{Select the statement that shows the medium population density of each region
 
{Select the statement that shows the medium population density of each region
 
|type="()"}
 
|type="()"}
- SELECT region, AVG(population/area) AS density FROM bbc
+
-A. SELECT region, AVG(population/area) AS density FROM bbc
- SELECT region, COUNT(population)/COUNT(area) AS density FROM bbc GROUP BY region
+
-B. SELECT region, COUNT(population)/COUNT(area) AS density FROM bbc GROUP BY region
- SELECT region, SUM(population)/COUNT(area) AS density FROM bbc GROUP BY region
+
-C. SELECT region, SUM(population)/COUNT(area) AS density FROM bbc GROUP BY region
- SELECT region, SUM(population)/SUM(area) AS density FROM bbc HAVING region
+
-D. SELECT region, SUM(population)/SUM(area) AS density FROM bbc HAVING region
+ SELECT region, SUM(population)/SUM(area) AS density FROM bbc GROUP BY region
+
+E. SELECT region, SUM(population)/SUM(area) AS density FROM bbc GROUP BY region
  
 
{Select the statement that shows the name and population density of the country with the largest population
 
{Select the statement that shows the name and population density of the country with the largest population
 
|type="()"}
 
|type="()"}
- SELECT name, density AS population/area FROM bbc WHERE population = MAX(population)
+
-A. 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)  
+
-B. 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)  
+
-C. 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)
+
+D. 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)  
+
-E. SELECT name, population/area AS density FROM bbc WHERE population > (SELECT MAX(population) FROM bbc)  
  
 
</quiz>
 
</quiz>
  
 
[[Category:Quizzes]]
 
[[Category:Quizzes]]

Revision as of 10:58, 23 July 2012

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

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

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

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

{Select the statement that shows the medium population density of each region |type="()"} -A. SELECT region, AVG(population/area) AS density FROM bbc -B. SELECT region, COUNT(population)/COUNT(area) AS density FROM bbc GROUP BY region -C. SELECT region, SUM(population)/COUNT(area) AS density FROM bbc GROUP BY region -D. SELECT region, SUM(population)/SUM(area) AS density FROM bbc HAVING region +E. SELECT region, SUM(population)/SUM(area) AS density FROM bbc GROUP BY region

{Select the statement that shows the name and population density of the country with the largest population |type="()"} -A. SELECT name, density AS population/area FROM bbc WHERE population = MAX(population) -B. SELECT name, density AS population/area FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) -C. SELECT name, MAX (population) FROM bbc WHERE population / (SELECT area FROM bbc) +D. SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) -E. SELECT name, population/area AS density FROM bbc WHERE population > (SELECT MAX(population) FROM bbc)

</quiz>