Difference between revisions of "Nobel Quiz"

From SQLZOO
Jump to: navigation, search
m
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Nobel Quiz
+
{{Languages}}
<div class='ref_section' style='float:right'>
+
<div class='ref_section'>
 
<table class='db_ref'>
 
<table class='db_ref'>
 
<caption>nobel</caption>
 
<caption>nobel</caption>
Line 41: Line 41:
 
</table>
 
</table>
 
</div>
 
</div>
<quiz shuffle=none display=simple>
+
<div class=quiz>
{Pick the code which shows the name of winner's names beginning with C and ending in n
+
<div class=q>Pick the code which shows the name of winner's names beginning with C and ending in n
|type="()"}
+
<syntaxhighlight class=d lang='sql'>
- <syntaxhighlight lang='sql'> SELECT name FROM nobel WHERE winner LIKE '%C%' AND winner LIKE '%n%' </syntaxhighlight>
+
SELECT name FROM nobel
- <syntaxhighlight lang='sql'> SELECT name FROM nobel WHERE winner LIKE '%C' AND winner LIKE 'n%' </syntaxhighlight>
+
WHERE winner LIKE '%C%' AND winner LIKE '%n%' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT name FROM nobel WHERE winner LIKE 'C%' AND winner LIKE '%n' </syntaxhighlight>
+
<syntaxhighlight class=d lang='sql'>
- <syntaxhighlight lang='sql'> SELECT winner FROM nobel WHERE winner LIKE '%C' AND winner LIKE 'n%' </syntaxhighlight>
+
SELECT name FROM nobel
+ <syntaxhighlight lang='sql'> SELECT winner FROM nobel WHERE winner LIKE 'C%' AND winner LIKE '%n' </syntaxhighlight>
+
WHERE winner LIKE '%C' AND winner LIKE 'n%' </syntaxhighlight>
 
+
<syntaxhighlight class=d lang='sql'>
{Select the code that shows how many Chemistry awards were given between 1950 and 1960
+
SELECT name FROM nobel
|type="()"}
+
WHERE winner LIKE 'C%' AND winner LIKE '%n' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT COUNT(subject) FROM nobel WHERE subject = 'Chemistry' AND BETWEEN 1950 and 1960 </syntaxhighlight>
+
<syntaxhighlight class=d lang='sql'>
- <syntaxhighlight lang='sql'> SELECT COUNT(subject) FROM nobel WHERE subject = 'Chemistry' AND yr BETWEEN (1950, 1960) </syntaxhighlight>
+
SELECT winner FROM nobel
+ <syntaxhighlight lang='sql'> SELECT COUNT(subject) FROM nobel WHERE subject = 'Chemistry' AND yr BETWEEN 1950 and 1960 </syntaxhighlight>
+
WHERE winner LIKE '%C' AND winner LIKE 'n%' </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT subject FROM nobel WHERE subject = 'Chemistry' AND yr BETWEEN 1950 and 1960 </syntaxhighlight>
+
<syntaxhighlight class='d y' lang='sql'>
- <syntaxhighlight lang='sql'> SELECT subject FROM nobel WHERE subject = 'Chemistry' AND yr BETWEEN (1950, 1960) </syntaxhighlight>
+
SELECT winner FROM nobel
 
+
WHERE winner LIKE 'C%' AND winner LIKE '%n' </syntaxhighlight>
{Pick the code that shows the amount of years where no Medicine awards were given
+
</div>
|type="()"}
+
<div class=q>Select the code that shows how many Chemistry awards were given between 1950 and 1960
- <syntaxhighlight lang='sql'> SELECT COUNT(DISTINCT yr) FROM nobel WHERE yr IN (SELECT DISTINCT yr FROM nobel WHERE subject <> 'Medicine') </syntaxhighlight>
+
<syntaxhighlight class=d lang='sql'>
+ <syntaxhighlight lang='sql'> SELECT COUNT(DISTINCT yr) FROM nobel WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine') </syntaxhighlight>
+
SELECT COUNT(subject) FROM nobel
- <syntaxhighlight lang='sql'> SELECT DISTINCT yr FROM nobel WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject LIKE 'Medicine') </syntaxhighlight>
+
WHERE subject = 'Chemistry'
- <syntaxhighlight lang='sql'> SELECT COUNT(DISTINCT yr) FROM nobel WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject NOT LIKE 'Medicine') </syntaxhighlight>
+
  AND BETWEEN 1950 and 1960 </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT COUNT(yr) FROM nobel WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine') </syntaxhighlight>
+
<syntaxhighlight class=d lang='sql'>
 
+
SELECT COUNT(subject) FROM nobel
{Select the result that would be obtained from the following code:  
+
WHERE subject = 'Chemistry'
 +
  AND yr BETWEEN (1950, 1960) </syntaxhighlight>
 +
<syntaxhighlight class='d y' lang='sql'>
 +
SELECT COUNT(subject) FROM nobel
 +
WHERE subject = 'Chemistry'
 +
  AND yr BETWEEN 1950 and 1960 </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT subject FROM nobel
 +
WHERE subject = 'Chemistry'
 +
  AND yr BETWEEN 1950 and 1960 </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT subject FROM nobel
 +
WHERE subject = 'Chemistry'
 +
  AND yr BETWEEN (1950, 1960) </syntaxhighlight>
 +
</div>
 +
<div class=q>Pick the code that shows the amount of years where no Medicine awards were given
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT COUNT(DISTINCT yr) FROM nobel
 +
WHERE yr IN (SELECT DISTINCT yr FROM nobel WHERE subject <> 'Medicine') </syntaxhighlight>
 +
<syntaxhighlight class='d y' lang='sql'>
 +
SELECT COUNT(DISTINCT yr) FROM nobel
 +
WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT DISTINCT yr FROM nobel
 +
WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject LIKE 'Medicine') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT COUNT(DISTINCT yr) FROM nobel
 +
WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject NOT LIKE 'Medicine') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT COUNT(yr) FROM nobel
 +
WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine') </syntaxhighlight>
 +
</div>
 +
<div class=q>Select the result that would be obtained from the following code:  
 
<syntaxhighlight lang='sql'>SELECT subject, winner FROM nobel WHERE winner LIKE 'Sir%' AND yr LIKE '196%'</syntaxhighlight>
 
<syntaxhighlight lang='sql'>SELECT subject, winner FROM nobel WHERE winner LIKE 'Sir%' AND yr LIKE '196%'</syntaxhighlight>
<table><caption>Table-A</caption><tr><td>Medicine</td><td>John Eccles</td></tr><tr><td>Medicine</td><td>Frank Macfarlane Burnet</td></tr></table>
+
<table class=d><tr><td>Medicine</td><td>John Eccles</td></tr><tr><td>Medicine</td><td>Frank Macfarlane Burnet</td></tr></table>
<table><caption>Table-B</caption><tr><td>Chemistry</td><td>Sir Cyril Hinshelwood</td></tr></table>
+
<table class=d><tr><td>Chemistry</td><td>Sir Cyril Hinshelwood</td></tr></table>
<table><caption>Table-C</caption><tr><td>Medicine</td><td>Sir John Eccles</td></tr><tr><td>Medicine</td><td>Sir Frank Macfarlane Burnet</td></tr></table>
+
<table class='y d'><tr><td>Medicine</td><td>Sir John Eccles</td></tr><tr><td>Medicine</td><td>Sir Frank Macfarlane Burnet</td></tr></table>
<table><caption>Table-D</caption><tr><td>Medicine</td><td>John Eccles</td></tr><tr><td>Medicine</td><td>Frank Macfarlane Burnet</td></tr><tr><td>Chemistry</td><td>Willard F.Libby</td></tr></table>
+
<table class=d><tr><td>Medicine</td><td>John Eccles</td></tr><tr><td>Medicine</td><td>Frank Macfarlane Burnet</td></tr><tr><td>Chemistry</td><td>Willard F.Libby</td></tr></table>
<table><caption>Table-E</caption><tr><td>Sir John Eccles</td></tr><tr><td>Sir Frank Macfarlane Burnet</td></tr></table>
+
<table class=d><tr><td>Sir John Eccles</td></tr><tr><td>Sir Frank Macfarlane Burnet</td></tr></table>
|type="()"}
+
</div>
- Table-A
 
- Table-B
 
+ Table-C
 
- Table-D
 
- Table-E
 
  
{Select the code which would show the year when neither a Physics or Chemistry award was given
+
<div class=q>Select the code which would show the year when neither a Physics or Chemistry award was given
|type="()"}
+
<syntaxhighlight class=d lang='sql'>
- <syntaxhighlight lang='sql'> SELECT yr FROM nobel WHERE subject NOT IN(SELECT yr from nobel WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
+
SELECT yr FROM nobel
- <syntaxhighlight lang='sql'> SELECT yr FROM nobel WHERE subject NOT IN(SELECT subject from nobel WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
+
WHERE subject NOT IN(SELECT yr  
+ <syntaxhighlight lang='sql'> SELECT yr FROM nobel WHERE yr NOT IN(SELECT yr from nobel WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
+
                        FROM nobel
- <syntaxhighlight lang='sql'> SELECT yr FROM nobel WHERE yr NOT IN(SELECT subject from nobel WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
+
                      WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
- <syntaxhighlight lang='sql'> SELECT yr FROM subject WHERE yr NOT IN(SELECT yr from nobel WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
+
<syntaxhighlight class=d lang='sql'>
 +
SELECT yr FROM nobel
 +
WHERE subject NOT IN(SELECT subject  
 +
                        FROM nobel
 +
                      WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
 +
<syntaxhighlight class='d y' lang='sql'>
 +
SELECT yr FROM nobel
 +
WHERE yr NOT IN(SELECT yr  
 +
                  FROM nobel
 +
                WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT yr FROM nobel
 +
WHERE yr NOT IN(SELECT subject
 +
                FROM nobel
 +
                WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT yr FROM subject
 +
WHERE yr NOT IN (SELECT yr
 +
                    FROM nobel
 +
                  WHERE subject IN ('Chemistry','Physics')) </syntaxhighlight>
 +
</div>
  
{Select the code which shows the years when a Medicine award was given but no Peace or Literature award was
+
<div class=q>Select the code which shows the years when a Medicine award was given but no Peace or Literature award was
|type="()"}
+
<syntaxhighlight class=d lang='sql'>
- <syntaxhighlight lang='sql'> SELECT DISTINCT yr FROM nobel WHERE subject='Medicine' and subject NOT IN(SELECT yr from nobel WHERE subject='Literature') and yr NOT IN (SELECT yr FROM nobel WHERE subject='Peace') </syntaxhighlight>
+
SELECT DISTINCT yr
- <syntaxhighlight lang='sql'> SELECT DISTINCT yr FROM nobel WHERE subject='Medicine' and yr NOT IN(SELECT yr from nobel WHERE subject='Literature' AND subject='Peace') </syntaxhighlight>
+
  FROM nobel
+ <syntaxhighlight lang='sql'> SELECT DISTINCT yr FROM nobel WHERE subject='Medicine' and yr NOT IN(SELECT yr from nobel WHERE subject='Literature') and yr NOT IN (SELECT yr FROM nobel WHERE subject='Peace') </syntaxhighlight>
+
WHERE subject='Medicine' AND
- <syntaxhighlight lang='sql'> SELECT DISTINCT yr FROM subject WHERE subject='Medicine' and yr NOT IN(SELECT yr from nobel WHERE subject='Literature' and subject='Peace') </syntaxhighlight>
+
      subject NOT IN(SELECT yr from nobel
- <syntaxhighlight lang='sql'> SELECT DISTINCT yr FROM subject WHERE subject='Medicine' and yr NOT IN(SELECT yr from nobel WHERE subject='Literature') and yr NOT IN (SELECT yr FROM nobel WHERE subject='Peace') </syntaxhighlight>
+
                      WHERE subject='Literature')
 
+
  AND  yr NOT IN (SELECT yr
{Pick the result that would be obtained from the following code:  
+
                    FROM nobel
 +
                  WHERE subject='Peace') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT DISTINCT yr
 +
  FROM nobel WHERE subject='Medicine'
 +
  AND yr NOT IN(SELECT yr from nobel
 +
                  WHERE subject='Literature'
 +
                    AND subject='Peace') </syntaxhighlight>
 +
<syntaxhighlight class='d y' lang='sql'>
 +
SELECT DISTINCT yr
 +
  FROM nobel
 +
WHERE subject='Medicine'  
 +
  AND yr NOT IN(SELECT yr FROM nobel  
 +
                  WHERE subject='Literature')
 +
  AND yr NOT IN (SELECT yr FROM nobel
 +
                  WHERE subject='Peace') </syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT DISTINCT yr
 +
  FROM subject
 +
WHERE subject='Medicine'
 +
  AND yr NOT IN(SELECT yr from nobel
 +
                  WHERE subject='Literature'
 +
                    AND subject='Peace')
 +
</syntaxhighlight>
 +
<syntaxhighlight class=d lang='sql'>
 +
SELECT DISTINCT yr
 +
  FROM subject
 +
WHERE subject='Medicine' AND
 +
  yr NOT IN('Literature','Peace') </syntaxhighlight>
 +
</div>
 +
<div class=q>Pick the result that would be obtained from the following code:  
 
<syntaxhighlight lang='sql'>
 
<syntaxhighlight lang='sql'>
 
  SELECT subject, COUNT(subject)  
 
  SELECT subject, COUNT(subject)  
Line 103: Line 180:
 
   GROUP BY subject
 
   GROUP BY subject
 
</syntaxhighlight>
 
</syntaxhighlight>
<table><caption>Table-A</caption><tr><td>1</td></tr><tr><td>1</td></tr><tr><td>2</td></tr><tr><td>1</td></tr><tr><td>1</td></tr></table>
+
<table class=d><tr><td>1</td></tr><tr><td>1</td></tr><tr><td>2</td></tr><tr><td>1</td></tr><tr><td>1</td></tr></table>
<table><caption>Table-B</caption><tr><td>Chemistry</td><td>6</td></tr></table>
+
<table class=d><tr><td>Chemistry</td><td>6</td></tr></table>
<table><caption>Table-C</caption><tr><td>Chemistry</td><td>3</td></tr><tr><td>Literature</td><td>1</td></tr><tr><td>Medicine</td><td>2</td></tr><tr><td>Peace</td><td>0</td></tr><tr><td>Physics</td><td>2</td></tr></table>
+
<table class=d><tr><td>Chemistry</td><td>3</td></tr><tr><td>Literature</td><td>1</td></tr><tr><td>Medicine</td><td>2</td></tr><tr><td>Peace</td><td>0</td></tr><tr><td>Physics</td><td>2</td></tr></table>
<table><caption>Table-D</caption><tr><td>Chemistry</td><td>1</td></tr><tr><td>Literature</td><td>1</td></tr><tr><td>Medicine</td><td>2</td></tr><tr><td>Peace</td><td>1</td></tr><tr><td>Physics</td><td>1</td></tr></table>
+
<table class='d y'><tr><td>Chemistry</td><td>1</td></tr><tr><td>Literature</td><td>1</td></tr><tr><td>Medicine</td><td>2</td></tr><tr><td>Peace</td><td>1</td></tr><tr><td>Physics</td><td>1</td></tr></table>
<table><caption>Table-E</caption><tr><td>Chemistry</td><td>1</td></tr><tr><td>Literature</td><td>1</td></tr><tr><td>Peace</td><td>1</td></tr><tr><td>Physics</td><td>1</td></tr></table>
+
<table class=d><tr><td>Chemistry</td><td>1</td></tr><tr><td>Literature</td><td>1</td></tr><tr><td>Peace</td><td>1</td></tr><tr><td>Physics</td><td>1</td></tr></table>
|type="()"}
+
</div>
- Table-A
 
- Table-B
 
- Table-C
 
+ Table-D
 
- Table-E
 
</quiz>
 
 
 
 
[[Category:Quizzes]]
 
[[Category:Quizzes]]

Latest revision as of 01:07, 8 January 2016

Language:Project:Language policy English  • 日本語 • 中文
nobel
yr subject winner
1960 Chemistry Willard F. Libby
1960 Literature Saint-John Perse
1960 Medicine Sir Frank Macfarlane Burnet
1960 Medicine Peter Medawar
1960 Physics Donald A. Glaser
1960 Peace Albert Lutuli
...
Pick the code which shows the name of winner's names beginning with C and ending in n
SELECT name FROM nobel
 WHERE winner LIKE '%C%' AND winner LIKE '%n%'
SELECT name FROM nobel
 WHERE winner LIKE '%C' AND winner LIKE 'n%'
SELECT name FROM nobel
 WHERE winner LIKE 'C%' AND winner LIKE '%n'
SELECT winner FROM nobel
 WHERE winner LIKE '%C' AND winner LIKE 'n%'
SELECT winner FROM nobel
 WHERE winner LIKE 'C%' AND winner LIKE '%n'
Select the code that shows how many Chemistry awards were given between 1950 and 1960
SELECT COUNT(subject) FROM nobel
 WHERE subject = 'Chemistry'
   AND BETWEEN 1950 and 1960
SELECT COUNT(subject) FROM nobel
 WHERE subject = 'Chemistry'
   AND yr BETWEEN (1950, 1960)
SELECT COUNT(subject) FROM nobel
 WHERE subject = 'Chemistry'
   AND yr BETWEEN 1950 and 1960
SELECT subject FROM nobel
 WHERE subject = 'Chemistry'
   AND yr BETWEEN 1950 and 1960
SELECT subject FROM nobel
 WHERE subject = 'Chemistry'
   AND yr BETWEEN (1950, 1960)
Pick the code that shows the amount of years where no Medicine awards were given
SELECT COUNT(DISTINCT yr) FROM nobel
 WHERE yr IN (SELECT DISTINCT yr FROM nobel WHERE subject <> 'Medicine')
SELECT COUNT(DISTINCT yr) FROM nobel
 WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine')
SELECT DISTINCT yr FROM nobel
 WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject LIKE 'Medicine')
SELECT COUNT(DISTINCT yr) FROM nobel
 WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject NOT LIKE 'Medicine')
SELECT COUNT(yr) FROM nobel
 WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine')
Select the result that would be obtained from the following code:
SELECT subject, winner FROM nobel WHERE winner LIKE 'Sir%' AND yr LIKE '196%'
MedicineJohn Eccles
MedicineFrank Macfarlane Burnet
ChemistrySir Cyril Hinshelwood
MedicineSir John Eccles
MedicineSir Frank Macfarlane Burnet
MedicineJohn Eccles
MedicineFrank Macfarlane Burnet
ChemistryWillard F.Libby
Sir John Eccles
Sir Frank Macfarlane Burnet
Select the code which would show the year when neither a Physics or Chemistry award was given
SELECT yr FROM nobel
 WHERE subject NOT IN(SELECT yr 
                        FROM nobel
                       WHERE subject IN ('Chemistry','Physics'))
SELECT yr FROM nobel
 WHERE subject NOT IN(SELECT subject 
                        FROM nobel
                       WHERE subject IN ('Chemistry','Physics'))
SELECT yr FROM nobel
 WHERE yr NOT IN(SELECT yr 
                   FROM nobel
                 WHERE subject IN ('Chemistry','Physics'))
SELECT yr FROM nobel
 WHERE yr NOT IN(SELECT subject
                 FROM nobel
                WHERE subject IN ('Chemistry','Physics'))
SELECT yr FROM subject
 WHERE yr NOT IN (SELECT yr
                    FROM nobel
                   WHERE subject IN ('Chemistry','Physics'))
Select the code which shows the years when a Medicine award was given but no Peace or Literature award was
SELECT DISTINCT yr
  FROM nobel
 WHERE subject='Medicine' AND
       subject NOT IN(SELECT yr from nobel
                      WHERE subject='Literature')
  AND  yr NOT IN (SELECT yr
                    FROM nobel
                   WHERE subject='Peace')
SELECT DISTINCT yr
  FROM nobel WHERE subject='Medicine'
   AND yr NOT IN(SELECT yr from nobel
                  WHERE subject='Literature'
                    AND subject='Peace')
SELECT DISTINCT yr
  FROM nobel
 WHERE subject='Medicine' 
   AND yr NOT IN(SELECT yr FROM nobel 
                  WHERE subject='Literature')
   AND yr NOT IN (SELECT yr FROM nobel
                   WHERE subject='Peace')
SELECT DISTINCT yr
  FROM subject
 WHERE subject='Medicine'
   AND yr NOT IN(SELECT yr from nobel
                  WHERE subject='Literature'
                    AND subject='Peace')
SELECT DISTINCT yr
  FROM subject
 WHERE subject='Medicine' AND
  yr NOT IN('Literature','Peace')
Pick the result that would be obtained from the following code:
 SELECT subject, COUNT(subject) 
   FROM nobel 
  WHERE yr ='1960' 
  GROUP BY subject
1
1
2
1
1
Chemistry6
Chemistry3
Literature1
Medicine2
Peace0
Physics2
Chemistry1
Literature1
Medicine2
Peace1
Physics1
Chemistry1
Literature1
Peace1
Physics1