1.
Montant total des ventes par pays
SELECT country, SUM(samount) AS total_sales
FROM SALES
GROUP BY country;
2. Montant total des ventes par mois de chaque année,
puis par année, et enfin le total général
-- Par mois et année
SELECT year, month, monthName, SUM(amount) AS total_sales
FROM SALES
GROUP CUBE ( year, month, monthName )
ORDER BY year, month;
-- Par année
SELECT year, SUM(amount) AS total_sales
FROM SALES
GROUP BY year
ORDER BY year;
-- Total général
SELECT SUM(amount) AS total_sales
FROM SALES;
3. Quantités du produit "Écran 22 pouces"
vendues
-- Par pays
SELECT country, SUM(quantity) AS total_quantity
FROM SALES
WHERE name = 'Écran 22 pouces'
GROUP BY country;
-- Par année
SELECT year, SUM(quantity) AS total_quantity
FROM SALES
WHERE [Link] = 'Écran 22 pouces'
GROUP BY year
ORDER BY year;
3. SUITE
-- Par année pour chaque pays
SELECT year, country, SUM(quantity) AS total_quantity
FROM SALES
WHERE [Link] = 'Écran 22 pouces'
GROUP BY year, country
ORDER BY year, country;
-- Total général
SELECT SUM(quantity) AS total_quantity
FROM SALES
WHERE [Link] = 'Écran 22 pouces';
4. Montant total des ventes : par pays, par année,
et par produit
-- Par pays
SELECT country, SUM(amount) AS total_sales
FROM SALES
GROUP BY country;
-- Par année
SELECT year, SUM(amount) AS total_sales
FROM SALES
GROUP BY year
ORDER BY year;
-- Par produit
SELECT name AS product_name, SUM(amount) AS total_sales
FROM SALES
GROUP BY [Link]