linfo2172-databases/P3/queries/query1.sql

13 lines
426 B
MySQL
Raw Normal View History

2024-04-24 11:31:15 +02:00
-- Author: Anatole Huet
2024-04-24 10:38:32 +02:00
-- 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.
2024-04-24 11:31:15 +02:00
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
2024-04-24 10:38:32 +02:00
;