Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Atelier - Sous requêtes

APERTO-NOTA

Atelier : Utilisation des sous-requêtes

1. Trouver les produits avec une quantité en stock inférieure à la moyenne

Solution to Exercise #
SELECT nom_produit 
FROM produits
WHERE unites_stock < (
    SELECT AVG(unites_stock) 
    FROM produits
);

2. Trouver les commandes avec des frais de port supérieurs à la moyenne pour chaque client

Solution to Exercise #
SELECT code_client, no_commande, port
FROM commandes c
WHERE port > (
    SELECT AVG(port) AS moyenne
    FROM commandes b
    WHERE c.code_client = b.code_client
);

3. Trouver les produits avec une quantité en stock supérieure à celle des produits de catégorie 3

Solution to Exercise #
SELECT ref_produit 
FROM produits
WHERE unites_stock > (
    SELECT MAX(unites_stock)
    FROM produits
    WHERE code_categorie = 3
);