Skip to content

Instantly share code, notes, and snippets.

@Hotfirenet
Created September 29, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hotfirenet/9f61b0ac64974c9f6769c300a9cf69ee to your computer and use it in GitHub Desktop.
Save Hotfirenet/9f61b0ac64974c9f6769c300a9cf69ee to your computer and use it in GitHub Desktop.
requête sql pour Prestashop qui permet de remonter la quantité d'un produit vendu sur une période par client
SELECT SUM(B.product_quantity) AS product_quantity
,C.id_customer
,C.company
FROM ps_orders A
INNER JOIN ps_order_detail B ON B.id_order = A.id_order
INNER JOIN ps_customer C ON C.id_customer = A.id_customer
WHERE B.product_id = 2734 AND CAST(A.date_add AS DATE) >= '2015-09-01'
GROUP BY C.id_customer, C.company
ORDER BY 1 DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment