Difference between revisions of "BBC QUIZ"

From SQLZOO
Jump to: navigation, search
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
BBC QUIZ
 
 
<div class='ref_section'>
 
<div class='ref_section'>
 
<table class='db_ref'>
 
<table class='db_ref'>
<caption>bbc</caption>
+
<caption>world</caption>
 
<tr>
 
<tr>
 
<th>name</th>
 
<th>name</th>
<th>region</th>
+
<th>continent</th>
 
<th>area</th>
 
<th>area</th>
 
<th>population</th>
 
<th>population</th>
Line 58: Line 57:
 
<td align='right'>9900</td>
 
<td align='right'>9900</td>
 
<td></td>
 
<td></td>
</tr>
 
 
</tr>
 
</tr>
 
<tr>
 
<tr>
Line 73: Line 71:
 
</div>
 
</div>
  
<quiz shuffle=none display=simple>
+
<div class=quiz>
{Select the code which gives the name of countries beginning with U
+
<div class=q>Select the code which gives the name of countries beginning with U
|type="()"}
+
<syntaxhighlight class=d lang='sql'>
- SELECT name FROM bbc WHERE name BEGIN with C
+
SELECT name
- SELECT name FROM bbc WHERE name LIKE '%C'
+
  FROM world
- SELECT name FROM bbc WHERE name LIKE '%C%'
+
WHERE name
- SELECT name FROM bbc WHERE name LIKE U
+
BEGIN with U</syntaxhighlight>
+ SELECT name FROM bbc WHERE name LIKE 'U%'
+
<syntaxhighlight class=d lang='sql'>
 
+
SELECT name
{Select the code which shows just the population of United Kingdom?
+
  FROM world
|type="()"}
+
WHERE name LIKE '%U' </syntaxhighlight>
- SELECT name FROM bbc WHERE name Like 'United%'
+
<syntaxhighlight class=d lang='sql'>
- SELECT name FROM bbc WHERE population = 'United Kingdom'
+
SELECT name
- SELECT name, population FROM bbc WHERE name = 'United Kingdom'
+
  FROM world
+ SELECT population FROM bbc WHERE name = 'United Kingdom'
+
WHERE name LIKE '%u%' </syntaxhighlight>
- SELECT population FROM bbc WHERE name = United Kingdom
+
<syntaxhighlight class=d lang='sql'>
 
+
SELECT name
{Select the answer which shows the problem with this SQL code:SELECT name FROM "bbc" WHERE population > '2000000'
+
  FROM world
|type="()"}
+
WHERE name LIKE U </syntaxhighlight>
- Apostrophes should be used around 'bbc' instead of speech marks
+
<syntaxhighlight class='d y' lang='sql'>
- There are apostrophes surrounding '2000000'
+
SELECT name
+ There are speech marks surrounding "bbc"
+
  FROM world
- There are speech marks surrounding "bbc" and there is apostrophes surrounding '2000000'
+
WHERE name LIKE 'U%' </syntaxhighlight>
- The use of a WHERE function is incorrect
+
</div>
 
+
<div class=q>Select the code which shows just the population of United Kingdom?
{Select the result that would be obtained from the following code: SELECT name, population / 10 FROM bbc WHERE population < 10000
+
<syntaxhighlight class=d lang='sql'>
<table style='float:left'><caption>Table-A</caption><tr><td>Andorra</td><td>6400</td></tr><tr><td>Nauru</td><td>990</td></tr></table>
+
SELECT population
<table style='float:left'><caption>Table-B</caption><tr><td>Andorra</td><td>64000</td></tr><tr><td>Nauru</td><td>9900</td></tr></table>
+
  FROM 'United Kingdom' </syntaxhighlight>
<table style='float:left'><caption>Table-C</caption><tr><td>Nauru</td><td>99</td></tr></table>
+
<syntaxhighlight class=d lang='sql'>
<table style='float:left'><caption>Table-D</caption><tr><td>Nauru</td><td>990</td></tr></table>
+
SELECT name
<table style='float:left'><caption>Table-E</caption><tr><td>Nauru</td><td>9900</td></tr></table>
+
  FROM world
|type="()"}
+
WHERE population = 'United Kingdom' </syntaxhighlight>
- Table-A
+
<syntaxhighlight class=d lang='sql'>
- Table-B
+
SELECT FROM world
- Table-C
+
WHERE population IN 'United Kingdom' </syntaxhighlight>
+ Table-D
+
<syntaxhighlight class='d y' lang='sql'>
- Table-E
+
SELECT population
 
+
  FROM world
{Select the code which would reveal the name and population of countries in Europe, North America and South America
+
WHERE name = 'United Kingdom' </syntaxhighlight>
|type="()"}
+
<syntaxhighlight class=d lang='sql'>
- SELECT name FROM bbc WHERE region IN ('Europe', 'North America', 'South America')
+
SELECT population
+ SELECT name, population FROM bbc WHERE region IN ('Europe', 'North America', 'South America')
+
  FROM world
- SELECT name, population FROM bbc WHERE region IN (Europe North America South America)
+
WHERE 'United Kingdom' IN name </syntaxhighlight>
- SELECT name, population FROM bbc WHERE region IS ('Europe', 'North America', 'South America')
+
</div>
- SELECT population FROM bbc WHERE region IN ('Europe', 'North America', 'South America')
+
<div class=q>Select the answer which shows the problem with this SQL code - the indended result should be the single row containing 'France':
 
+
<syntaxhighlight lang='sql'>
{Select the code which would give two rows
+
SELECT continent
|type="()"}
+
  FROM world
- SELECT name FROM bbc WHERE name = 'United Kingdom'
+
  WHERE 'name' = 'France'
- SELECT name FROM bbc WHERE name = 'United Kingdom' AND name = 'Algeria'
+
</syntaxhighlight>
- SELECT name FROM bbc WHERE name EITHER ('United Kingdom', 'Algeria')
+
<div class=d>continent should be 'continent'</div>
+ SELECT name FROM bbc WHERE name IN ('United Kingdom', 'Algeria')
+
<div class='d y'>'name' should be name</div>
- SELECT name FROM WHERE name IS 'Scotland'
+
<div class=d>'France' should be "France"</div>
 
+
<div class=d>'France' should be France</div>
{Select the result that would be obtained from this code:  
+
<div class=d>= should be IN</div>
<source lang='SQL'>SELECT name FROM bbc WHERE region = 'South America' AND population > 40000000</source>
+
</div>
<table style='float:left'><caption>Table-A</caption><tr><td>Afghanistan</td></tr><tr><td>Brazil</td></tr><tr><td>Colombia</td></tr></table>
+
<div class=q>Select the result that would be obtained from the following code:  
<table style='float:left'><caption>Table-B</caption><tr><td>Brazil</td></tr></table>
+
<syntaxhighlight lang='sql'>
<table style='float:left'><caption>Table-C</caption><tr><td>Brazil</td></tr><tr><td>Colombia</td></tr></table>
+
SELECT name, population / 10  
<table style='float:left'><caption>Table-D</caption><tr><td>Brazil</td><td>South America</td></tr><tr><td>Colombia</td><td>South America</td></tr></table>
+
  FROM world
<table style='float:left'><caption>Table-E</caption><tr><td>Brazil</td><td>182800000</td></tr><tr><td>Colombia</td><td>45600000</td></tr></table>
+
WHERE population < 10000
|type="()"}
+
</syntaxhighlight>
- Table-A
+
<table class=d><tr><td>Andorra</td><td>6400</td></tr><tr><td>Nauru</td><td>990</td></tr></table>
- Table-B
+
<table class=d><tr><td>Andorra</td><td>64000</td></tr><tr><td>Nauru</td><td>9900</td></tr></table>
+ Table-C
+
<table class=d><tr><td>Nauru</td><td>99</td></tr></table>
- Table-D
+
<table class='d y'><tr><td>Nauru</td><td>990</td></tr></table>
- Table-E
+
<table class=d><tr><td>Nauru</td><td>9900</td></tr></table>
</quiz>
+
</div>
 +
<div class=q>Select the code which would reveal the name and population of countries in Europe and Asia
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name
 +
  FROM world
 +
WHERE continent IN ('Europe', 'Asia') </syntaxhighlight>
 +
<syntaxhighlight class='d y' lang='sql'>
 +
SELECT name, population
 +
  FROM world
 +
WHERE continent IN ('Europe', 'Asia') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name, population
 +
  FROM world
 +
WHERE name IN (Europe Asia) </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name, population
 +
  FROM world
 +
WHERE name IS ('Europe', 'Asia') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name, population
 +
  FROM world
 +
WHERE continent = ('Europe', 'Asia') </syntaxhighlight>
 +
</div>
 +
<div class=q >Select the code which would give two rows
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name FROM world
 +
WHERE name = 'Cuba' </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name FROM world
 +
WHERE name = 'Cuba'
 +
  AND name = 'Togo' </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name FROM world
 +
WHERE name EITHER ('Cuba', 'Togo') </syntaxhighlight>
 +
<syntaxhighlight class='d y' lang='sql'>
 +
SELECT name FROM world
 +
WHERE name IN ('Cuba', 'Togo') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT name FROM WHERE name IS 'Mali' </syntaxhighlight>
 +
</div>
 +
<div class=q>Select the result that would be obtained from this code:  
 +
<source lang='SQL'>
 +
SELECT name FROM world
 +
WHERE continent = 'South America'
 +
  AND population > 40000000</source>
 +
<table class=d><tr><td>Afghanistan</td></tr><tr><td>Brazil</td></tr><tr><td>Colombia</td></tr></table>
 +
<table class=d><tr><td>Brazil</td></tr></table>
 +
<table class='d y'><tr><td>Brazil</td></tr><tr><td>Colombia</td></tr></table>
 +
<table class=d><tr><td>Brazil</td><td>South America</td></tr><tr><td>Colombia</td><td>South America</td></tr></table>
 +
<table class=d><tr><td>Brazil</td><td>182800000</td></tr><tr><td>Colombia</td><td>45600000</td></tr></table>
 +
</div>
 +
</div>
 
[[Category:Quizzes]]
 
[[Category:Quizzes]]

Latest revision as of 08:30, 15 May 2015

world
name continent area population gdp
Afghanistan South Asia 652225 26000000
Albania Europe 28728 3200000 6656000000
Algeria Middle East 2400000 32900000 75012000000
Andorra Europe 468 64000
Brazil South America 8550000 182800000 564852000000
Colombia South America 1140000 45600000
Nauru Asia-Pacific 21 9900
Uzbekistan Central Asia 447000 26000000
...
Select the code which gives the name of countries beginning with U
SELECT name
  FROM world
 WHERE name
 BEGIN WITH U
SELECT name
  FROM world
 WHERE name LIKE '%U'
SELECT name
  FROM world
 WHERE name LIKE '%u%'
SELECT name
  FROM world
 WHERE name LIKE U
SELECT name
  FROM world
 WHERE name LIKE 'U%'
Select the code which shows just the population of United Kingdom?
SELECT population
  FROM 'United Kingdom'
SELECT name
  FROM world
 WHERE population = 'United Kingdom'
SELECT FROM world
 WHERE population IN 'United Kingdom'
SELECT population
  FROM world
 WHERE name = 'United Kingdom'
SELECT population
  FROM world
 WHERE 'United Kingdom' IN name
Select the answer which shows the problem with this SQL code - the indended result should be the single row containing 'France':
 SELECT continent 
   FROM world 
  WHERE 'name' = 'France'
continent should be 'continent'
'name' should be name
'France' should be "France"
'France' should be France
= should be IN
Select the result that would be obtained from the following code:
 SELECT name, population / 10 
  FROM world 
 WHERE population < 10000
Andorra6400
Nauru990
Andorra64000
Nauru9900
Nauru99
Nauru990
Nauru9900
Select the code which would reveal the name and population of countries in Europe and Asia
SELECT name
  FROM world 
 WHERE continent IN ('Europe', 'Asia')
SELECT name, population
  FROM world
 WHERE continent IN ('Europe', 'Asia')
SELECT name, population
  FROM world
 WHERE name IN (Europe Asia)
SELECT name, population
  FROM world
 WHERE name IS ('Europe', 'Asia')
SELECT name, population
  FROM world
 WHERE continent = ('Europe', 'Asia')
Select the code which would give two rows
SELECT name FROM world
 WHERE name = 'Cuba'
SELECT name FROM world
 WHERE name = 'Cuba'
   AND name = 'Togo'
SELECT name FROM world
 WHERE name EITHER ('Cuba', 'Togo')
SELECT name FROM world
 WHERE name IN ('Cuba', 'Togo')
SELECT name FROM WHERE name IS 'Mali'
Select the result that would be obtained from this code:
SELECT name FROM world
 WHERE continent = 'South America'
   AND population > 40000000
Afghanistan
Brazil
Colombia
Brazil
Brazil
Colombia
BrazilSouth America
ColombiaSouth America
Brazil182800000
Colombia45600000