-- q10 Show the info for the 'Medicine' prize before 1910, and Literature after 2004 inclusively
SELECT*
FROMnobel
WHERE(subject='Literature'ANDyr>=2004)
OR(subject='Medicine'ANDyr<1910)
OR(subject='Medicine'ANDyr<1910);
-- q11 Find all of the prizes by Peter Grünberg
SELECT*
FROMnobel
WHEREname='Peter Grünberg'
WHEREname='Peter Grünberg';
-- he didn't expect this to work, lol. I think this newer database engine uses UTF-8 encoding for the data, and thus there is no problem there
-- sad excuse for LIKE demonstrated here. He does mention it's bad to do this
SELECT*
FROMnobel
WHEREnameLIKE'Peter Gr%nberg'
WHEREnameLIKE'Peter Gr%nberg';
-- can also use CHAR(252) to show ü. Not sure why you would need to do this since you can type this particular character, but I guess if your name has newlines in it that this would matter.
SELECT*
FROMnobel
WHEREwinner='Peter Gr'||CHAR(252)||'nberg';
-- q12 find this other guy
SELECT*
FROMnobel
WHEREwinner='Eugene O''Niell';
-- q13 find winners that have names that start with 'Sir', and in the order name, year, subject
SELECTwinner,year,subject
FROMnobel
WHEREwinnerLIKE'Sir %'
ORDERBYyrDESC,winner;
-- dataset is now world(name, continent, area, population, gdp)
-- q1 list each country name where the population is larger than that of Russia
SELECTname
FROMworld
WHEREpopulation>(
SELECTpopulation
FROMworld
WHEREname='Russia'
);
-- note - you can only expect one result to be returned from the nested query, otherwise it will fail. For example, returning all countries numbers that have an R to start the name of the country will fail.
-- could have also done the population straight.
SELECTname
FROMworld
WHEREpopulation>1460000000;
-- "cheating"
-- q2 show the countries with a per capita GDP greater than the UK
SELECTname
FROMworld
WHEREcontinent='Europe'
ANDgdp/population>(
SELECTgdp/populationASpercapitagdp
FROMworld
WHEREname='United Kingdom'
);
-- q3 List the names and continent of countries in the continents containng either Argentena or Australia, and order by country