Difference between revisions of "BBC QUIZ"

From SQLZOO
Jump to: navigation, search
Line 1: Line 1:
BBC QUIZ
 
 
<div class='ref_section'>
 
<div class='ref_section'>
 
<table class='db_ref'>
 
<table class='db_ref'>
Line 72: Line 71:
 
</div>
 
</div>
  
<quiz shuffle=none display=simple>
+
<div class=quiz shuffle=none display=simple>
{Select the code which gives the name of countries beginning with U
+
<div ans=4>Select the code which gives the name of countries beginning with U
|type="()"}
+
<syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name BEGIN with U </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name BEGIN with U </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE '%U' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE '%U' </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE '%u%' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE '%u%' </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE U </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE U </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE 'U%' </syntaxhighlight>
+ <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name LIKE 'U%' </syntaxhighlight>
+
</div>
  
{Select the code which shows just the population of United Kingdom?
+
<div ans=3>Select the code which shows just the population of United Kingdom?
|type="()"}
+
<syntaxhighlight lang='sql'> SELECT population FROM 'United Kingdom' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT population FROM 'United Kingdom' </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE population = 'United Kingdom' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE population = 'United Kingdom' </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT FROM bbc WHERE population IN 'United Kingdom' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT FROM bbc WHERE population IN 'United Kingdom' </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT population FROM bbc WHERE name = 'United Kingdom' </syntaxhighlight>
+ <syntaxhighlight lang='sql'> SELECT population FROM bbc WHERE name = 'United Kingdom' </syntaxhighlight>
+
<syntaxhighlight lang='sql'> SELECT population FROM bbc WHERE 'United Kingdom' IN name </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT population FROM bbc WHERE 'United Kingdom' IN name </syntaxhighlight>
+
</div>
 
+
</div>
{Select the answer which shows the problem with this SQL code - the indended result should be the single row containing 'Europe':
 
<syntaxhighlight lang='sql'>
 
SELECT region
 
  FROM bbc
 
  WHERE 'name' = 'France'
 
</syntaxhighlight>
 
|type="()"}
 
- region should be 'region'
 
+ '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:
 
<syntaxhighlight lang='sql'>
 
SELECT name, population / 10
 
  FROM bbc
 
WHERE population < 10000
 
</syntaxhighlight>
 
<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>
 
<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>
 
<table style='float:left'><caption>Table-C</caption><tr><td>Nauru</td><td>99</td></tr></table>
 
<table style='float:left'><caption>Table-D</caption><tr><td>Nauru</td><td>990</td></tr></table>
 
<table style='float:left'><caption>Table-E</caption><tr><td>Nauru</td><td>9900</td></tr></table>
 
|type="()"}
 
- Table-A
 
- Table-B
 
- Table-C
 
+ Table-D
 
- Table-E
 
 
 
{Select the code which would reveal the name and population of countries in Europe, North America and South America
 
|type="()"}
 
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE region IN ('Europe', 'North America', 'South America') </syntaxhighlight>
 
+ <syntaxhighlight lang='sql'> SELECT name, population FROM bbc WHERE region IN ('Europe', 'North America', 'South America') </syntaxhighlight>
 
- <syntaxhighlight lang='sql'> SELECT name, population FROM bbc WHERE region IN (Europe North America South America) </syntaxhighlight>
 
- <syntaxhighlight lang='sql'> SELECT name, population FROM bbc WHERE region IS ('Europe', 'North America', 'South America') </syntaxhighlight>
 
- <syntaxhighlight lang='sql'> SELECT population FROM bbc WHERE region IN ('Europe', 'North America', 'South America') </syntaxhighlight>
 
 
 
{Select the code which would give two rows
 
|type="()"}
 
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name = 'United Kingdom' </syntaxhighlight>
 
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name = 'United Kingdom' AND name = 'Algeria' </syntaxhighlight>
 
- <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name EITHER ('United Kingdom', 'Algeria') </syntaxhighlight>
 
+ <syntaxhighlight lang='sql'> SELECT name FROM bbc WHERE name IN ('United Kingdom', 'Algeria') </syntaxhighlight>
 
- <syntaxhighlight lang='sql'> SELECT name FROM WHERE name IS 'Scotland' </syntaxhighlight>
 
 
 
{Select the result that would be obtained from this code:
 
<source lang='SQL'>SELECT name FROM bbc WHERE region = 'South America' AND population > 40000000</source>
 
<table style='float:left'><caption>Table-A</caption><tr><td>Afghanistan</td></tr><tr><td>Brazil</td></tr><tr><td>Colombia</td></tr></table>
 
<table style='float:left'><caption>Table-B</caption><tr><td>Brazil</td></tr></table>
 
<table style='float:left'><caption>Table-C</caption><tr><td>Brazil</td></tr><tr><td>Colombia</td></tr></table>
 
<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>
 
<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>
 
|type="()"}
 
- Table-A
 
- Table-B
 
+ Table-C
 
- Table-D
 
- Table-E
 
</quiz>
 
 
[[Category:Quizzes]]
 
[[Category:Quizzes]]

Revision as of 20:40, 19 April 2015

bbc
name region 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 bbc WHERE name BEGIN with U
 SELECT name FROM bbc WHERE name LIKE '%U'
 SELECT name FROM bbc WHERE name LIKE '%u%'
 SELECT name FROM bbc WHERE name LIKE U
 SELECT name FROM bbc WHERE name LIKE 'U%'
Select the code which shows just the population of United Kingdom?
 SELECT population FROM 'United Kingdom'
 SELECT name FROM bbc WHERE population = 'United Kingdom'
 SELECT FROM bbc WHERE population IN 'United Kingdom'
 SELECT population FROM bbc WHERE name = 'United Kingdom'
 SELECT population FROM bbc WHERE 'United Kingdom' IN name