haki Posted January 23, 2018 Share Posted January 23, 2018 Bonjour , Je suis à la recherche du code SQL afin de savoir combien de produits j'ai vendu et définir une date. Exemple : j'aimerais savoir pour l'année 2017 , combien d'enveloppe j'ai vendu. SELECT o.id_order AS 'Num commande', p.name AS 'Produit', p.id_product AS 'IDProduit', sum(r.quantity) AS 'Quantite', o.date_add AS 'Date de Commande' FROM ps_customer c1, ps_customer c2, ps_address a1, ps_address a2, ps_country_lang y1, ps_country_lang y2, ps_country n, ps_product_lang p, ps_cart_product r, ps_orders o WHERE o.valid=1 AND o.id_address_invoice=a1.id_address AND o.id_address_delivery=a2.id_address AND o.id_cart = r.id_cart AND r.id_product = p.id_product AND p.id_lang=1 AND a1.id_country = y1.id_country AND a2.id_country = y2.id_country AND y1.id_lang=1 AND y2.id_lang=1 AND a1.id_customer=c1.id_customer AND a2.id_customer=c2.id_customer AND a2.id_country=n.id_country AND p.name like '%envel%' AND o.date_add like '2017%' Group by IDProduit ORDER BY Quantite DESC; Voici ce que j'ai déja fait mais il y a des incohérences Link to comment Share on other sites More sharing options...
doekia Posted January 23, 2018 Share Posted January 23, 2018 ps_order_detail est la clé de voute de ta requête Link to comment Share on other sites More sharing options...
Eolia Posted January 23, 2018 Share Posted January 23, 2018 Comment que tu parles trop bien ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now