Nobel Quiz

From SQLZOO
Jump to: navigation, search
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