23 lines
866 B
MySQL
23 lines
866 B
MySQL
|
//Exo 1 :
|
||
|
UPDATE ligne_commande
|
||
|
SET prix_total = (SELECT prix_unitaire * quantite From Produit WHERE ligne_commande.produit_id = Produit.id);
|
||
|
|
||
|
//Exo 2 :
|
||
|
SELECT client.id, commande_id, ligne_commande.id
|
||
|
FROM client JOIN commande3 on client.id = commande3.client_id JOIN ligne_commande ON commande3.id = ligne_commande.commande_id
|
||
|
WHERE client.id = 16;
|
||
|
|
||
|
SELECT client.nom, client.prenom, client.email, client.ville
|
||
|
FROM client JOIN commande3 ON client.id = commande3.client_id
|
||
|
WHERE commande3.date_achat BETWEEN '01-JAN-2019' AND '31-JAN-2019';
|
||
|
|
||
|
//Exo 3 :
|
||
|
SELECT client.id, client.nom, client.prenom, SUM(ligne_commande.prix_total) as montant_total
|
||
|
FROM client
|
||
|
JOIN commande3 ON client.id = commande3.client_id
|
||
|
JOIN ligne_commande ON commande3.id = ligne_commande.commande_id
|
||
|
GROUP BY client.id, client.nom, client.prenom
|
||
|
ORDER BY montant_total desc;
|
||
|
|
||
|
//Exo 4 :
|