16 lines
822 B
SQL
16 lines
822 B
SQL
-- List for each continent and each possible number of items per purchase (in the range 1...10), the corresponding number of purchases. Only consider countries that are 100% located in their respective continents.
|
|
|
|
-- How do you treat the default case as showed in the instructions?
|
|
-- Expected Heading: RELATION {continent CHARACTER, qty INTEGER, cnt INTEGER}
|
|
-- How do you treat the case where a country is splitted into two continents?
|
|
|
|
SELECT continent.name AS continent, qty, COUNT(qty) AS cnt
|
|
FROM continent
|
|
JOIN Encompasses ON Encompasses.continent = continent.name AND Encompasses.percentage = 100.0
|
|
JOIN country ON country.code = Encompasses.country
|
|
JOIN province ON province.country = country.code
|
|
JOIN Purchases ON Purchases.province = province.ROWID
|
|
WHERE qty <= 10 AND qty >= 1
|
|
GROUP BY continent.name, qty
|
|
;
|