-- Author: Anatole Huet

-- Determine the 10 countries with the most purchases; list the names of these countries, as well as the number of purchases; sort the results in decreasing order of purchases.

SELECT Country.name, COUNT(Purchases.id) as cnt
FROM Purchases
    JOIN Province ON Purchases.province = Province.rowid
    JOIN Country ON Province.country = Country.code
GROUP BY Country.name
ORDER BY cnt DESC
LIMIT 10
;
