Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion select-from-nobel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The expression subject IN ('Chemistry','Physics') can be used as a value - it wi

Show the 1984 winners ordered by subject and winner name; but list Chemistry and Physics last.
*/
SELECT winner, subject, subject IN ('Physics','Chemistry')
SELECT winner, subject
FROM nobel
WHERE yr=1984
ORDER BY subject IN ('Physics','Chemistry'),subject,winner
11 changes: 6 additions & 5 deletions select-from-world.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ Show per-capita GDP for the trillion dollar countries to the nearest $1000.
*/
SELECT name, ROUND(gdp/population, -3)
FROM world
WHERE gdp > 1000000000000
WHERE gdp >= 1000000000000

--#11
/*
The CASE statement shown is used to substitute North America for Caribbean in the third column.

Show the name and the continent - but substitute Australasia for Oceania - for countries beginning with N.
*/
SELECT name, continent,
CASE WHEN continent='Caribbean' THEN 'North America'
SELECT name,
CASE WHEN continent='Oceania' THEN 'Australasia'
ELSE continent END
FROM world
WHERE name LIKE 'J%'
FROM world
WHERE name LIKE 'N%'

--#12
/*
Expand Down Expand Up @@ -132,4 +132,5 @@ CASE WHEN continent = 'Oceania' THEN 'Australasia'
WHEN continent = 'Caribbean' AND name NOT LIKE 'b%' THEN 'South America'
ELSE continent END
FROM world
WHERE tld IN ('.ag','.ba','.bb','.ca','.cn','.nz','.ru','.tr','.uk')
ORDER BY name