Alright, this one (3a; sample problem with provided answer) has got me scratching my head:
bbc(name, region, area, population, gdp)
3a. Find the largest country in each region:
SELECT region, name, population
FROM bbc x
WHERE population >= ALL
(SELECT population
FROM bbc y
WHERE y.region = x.region
AND population > 0)
I understand the concept of 'WHERE y.region = x.region
' when I think about it in terms of the db engine looping over the table entries and matching each x.region with the current y.region (in the nested SELECT)... but wtf does 'AND population > 0
' do? It isn't a right answer without it, but I don't see how not...