Difference between revisions of "SUM and COUNT Quiz/ja"

From SQLZOO
Jump to: navigation, search
(Created page with "{{Languages}} SUM and COUNT QUIZ <div class='ref_section'> <table class='db_ref'> <caption>bbc</caption> <tr> <th>name</th> <th>region</th> <th>area</th> <th>population</th> <...")
 
Line 1: Line 1:
 
{{Languages}}
 
{{Languages}}
SUM and COUNT QUIZ
+
SUM COUNT クイズ
 
<div class='ref_section'>
 
<div class='ref_section'>
 
<table class='db_ref'>
 
<table class='db_ref'>
Line 45: Line 45:
 
</div>
 
</div>
 
<div class=quiz>
 
<div class=quiz>
<div class=q>Select the statement that shows the sum of population of all countries in 'Europe'
+
<div class=q>ヨーロッパの全ての国の人口を集計する文を選べ
 
<syntaxhighlight class=d lang='sql'> SELECT name, population FROM bbc WHERE region = 'Europe' </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT name, population FROM bbc WHERE region = 'Europe' </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT population FROM bbc WHERE region = 'Europe' SUM BY region </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT population FROM bbc WHERE region = 'Europe' SUM BY region </syntaxhighlight>
Line 53: Line 53:
 
</div>
 
</div>
  
<div class=q>Select the statement that shows the number of countries with population smaller than 150000
+
<div class=q>150000人よりも少ない人口の国の数を表示する文を選べ
 
<syntaxhighlight class=d class='d y' lang='sql'> SELECT COUNT(name) FROM bbc WHERE population < 150000 </syntaxhighlight>
 
<syntaxhighlight class=d class='d y' lang='sql'> SELECT COUNT(name) FROM bbc WHERE population < 150000 </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT COUNT(population < 150000) FROM bbc </syntaxhighlight>  
 
<syntaxhighlight class=d lang='sql'> SELECT COUNT(population < 150000) FROM bbc </syntaxhighlight>  
Line 61: Line 61:
 
</div>
 
</div>
  
<div class=q>Select the list of core SQL aggregate functions
+
<div class=q>SQL の主要な集計関数のリストを選べ
 
<div class=d>AVG(), COUNT(), FIRST(), LAST(), SUM()</div>
 
<div class=d>AVG(), COUNT(), FIRST(), LAST(), SUM()</div>
 
<div class=d>AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM()</div>
 
<div class=d>AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM()</div>
Line 69: Line 69:
 
</div>
 
</div>
  
<div class=q>Select the result that would be obtained from the following code:
+
<div class=q>次のコードの実行結果を選べ:
 
<syntaxhighlight lang='sql'>
 
<syntaxhighlight lang='sql'>
 
  SELECT region, SUM(area)
 
  SELECT region, SUM(area)
Line 79: Line 79:
 
<table class=d><caption>Table-B</caption><tr><td>Europe</td><td>17000000</td></tr><tr><td>Asia-Pacific</td><td>23460000</td></tr><tr><td>North America</td><td>21660000</td></tr></table>
 
<table class=d><caption>Table-B</caption><tr><td>Europe</td><td>17000000</td></tr><tr><td>Asia-Pacific</td><td>23460000</td></tr><tr><td>North America</td><td>21660000</td></tr></table>
 
<table  class=d><caption>Table-C</caption><tr><td>Europe</td></tr><tr><td>Asia-Pacific</td></tr><tr><td>North America</td></tr></table>
 
<table  class=d><caption>Table-C</caption><tr><td>Europe</td></tr><tr><td>Asia-Pacific</td></tr><tr><td>North America</td></tr></table>
<div class=d>No result due to invalid use of the GROUP BY function</div>
+
<div class=d>GROUP BY の用法が正しくないため結果は無し</div>
<div class='d y'>No result due to invalid use of the WHERE function</div>
+
<div class='d y'>WHERE の用法が正しくないため結果は無し</div>
 
</div>
 
</div>
  
<div class=q>Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark'
+
<div class=q>'Poland', 'Germany', 'Denmark' の人口の平均を表示するコードを選べ
 
<syntaxhighlight class=d lang='sql'> SELECT AVG(population) FROM bbc WHERE name = ('Poland', 'Germany', 'Denmark') </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT AVG(population) FROM bbc WHERE name = ('Poland', 'Germany', 'Denmark') </syntaxhighlight>
 
<syntaxhighlight class=d class='d y' lang='sql'> SELECT AVG(population) FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark') </syntaxhighlight>
 
<syntaxhighlight class=d class='d y' lang='sql'> SELECT AVG(population) FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark') </syntaxhighlight>
Line 91: Line 91:
 
</div>
 
</div>
  
<div class=q>Select the statement that shows the medium population density of each region
+
<div class=q>各地域の人口密度の中央値を表示するコードを選べ
 
<syntaxhighlight class=d lang='sql'> SELECT region, AVG(population/area) AS density FROM bbc </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT region, AVG(population/area) AS density FROM bbc </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT region, COUNT(population)/COUNT(area) AS density FROM bbc GROUP BY region </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT region, COUNT(population)/COUNT(area) AS density FROM bbc GROUP BY region </syntaxhighlight>
Line 99: Line 99:
 
</div>
 
</div>
  
<div class=q>Select the statement that shows the name and population density of the country with the largest population
+
<div class=q>人口密度と人口が最大の国名を表示するコードを選べ
 
<syntaxhighlight class=d lang='sql'> SELECT name, density AS population/area FROM bbc WHERE population = MAX(population) </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT name, density AS population/area FROM bbc WHERE population = MAX(population) </syntaxhighlight>
 
<syntaxhighlight class=d lang='sql'> SELECT name, density AS population/area FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) </syntaxhighlight>  
 
<syntaxhighlight class=d lang='sql'> SELECT name, density AS population/area FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) </syntaxhighlight>  
Line 107: Line 107:
 
</div>
 
</div>
  
<div class=q>Pick the result that would be obtained from the following code:  
+
<div class=q>次のコードの実行結果を選べ:  
 
<syntaxhighlight lang='sql'>
 
<syntaxhighlight lang='sql'>
 
  SELECT region, SUM(area)  
 
  SELECT region, SUM(area)  

Revision as of 17:59, 18 April 2018

Language:Project:Language policy English  • 日本語

SUM と COUNT クイズ

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
...
ヨーロッパの全ての国の人口を集計する文を選べ
 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'
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
SQL の主要な集計関数のリストを選べ
AVG(), COUNT(), FIRST(), LAST(), SUM()
AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM()
AVG(), COUNT(), CONCAT(), FIRST(), LAST(), MAX(), MIN(), SUM()
AVG(), COUNT(), MAX(), MIN(), SUM()
COUNT(), SUM()
次のコードの実行結果を選べ:
 SELECT region, SUM(area)
   FROM bbc 
  WHERE SUM(area) > 15000000 
  GROUP BY region
Table-A
Europe17000000
Table-B
Europe17000000
Asia-Pacific23460000
North America21660000
Table-C
Europe
Asia-Pacific
North America
GROUP BY の用法が正しくないため結果は無し
WHERE の用法が正しくないため結果は無し
'Poland', 'Germany', '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')
各地域の人口密度の中央値を表示するコードを選べ
 SELECT region, AVG(population/area) AS density FROM bbc
 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
 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
人口密度と人口が最大の国名を表示するコードを選べ
 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)
次のコードの実行結果を選べ:
 SELECT region, SUM(area) 
   FROM bbc 
  GROUP BY region 
  HAVING SUM(area)<= 20000000
Table-A
732240
13403102
17740392
4943771
Table-B
Africa22550927
Asia-Pacific28759578
Europe23866987
North America21660000
Table-C
Africa
Asia-Pacific
Europe
North America
Table-D
Americas732240
Middle East13403102
South America17740392
South Asia9437710
Table-E
Americas
Middle East
South America
South Asia