nobel table

yr

subject

winner

1960

Chemistry

Willard F. Libby

1960

Literature

Saint-John Perse

1960

Medicine

Sir Frank Macfarlane Burnet

1960

Medicine

Peter Madawar

...

Apostrophe

Find all details of the prize won by EUGENE O'NEILL

SELECT *
FROM nobel
WHERE winner = 'EUGENE O''NEILL';

Note: Escaping single quotes

You can't put a single quote in a quote string directly. You can use two single quotes within a quoted string.

Chemistry and Physics last

Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.

SELECT winner, subject
FROM nobel
WHERE yr = 1984
ORDER BY subject IN ('Chemistry','Physics'), subject, winner;

Note: The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1. Here we order by this value first, such that Chemistry and Physics stay at the last.

The amount of years where no Medicine awards were given

SELECT COUNT(DISTINCT yr) 
FROM nobel
WHERE yr NOT IN (SELECT DISTINCT yr FROM nobel WHERE subject = 'Medicine');

Last updated