Jump to content

[SQL] Quantité de produits vendus + Stock dispo

Recommended Posts



Sauriez-vous m'aider à modifier cette requête pour pouvoir afficher le stock disponible par déclinaison à l'instant T

Merci à la communauté de votre aide


select  od.product_id as ID_produit, pl.name as Nom, GROUP_CONCAT(DISTINCT(pagl.name) SEPARATOR ", ") AS 'Déclinaison', GROUP_CONCAT(DISTINCT(pal.name) SEPARATOR ", ") AS 'Valeur',
	(sum(od.product_quantity) - sum(od.product_quantity_return)) AS Quantités,
	COUNT(*) AS Ventes
from ps_order_detail od
inner join ps_orders o on (o.id_order = od.id_order and o.invoice_date between '2020-12-07 00:00:00' and '2020-12-31 23:59:59')
inner join ps_product_lang pl on(pl.id_product = od.product_id)
left join ps_product_attribute_combination pac on(pac.id_product_attribute = od.product_attribute_id)
left join ps_attribute pa on (pa.id_attribute = pac.id_attribute)
left join ps_attribute_group_lang pagl on(pagl.id_attribute_group = pa.id_attribute_group and pagl.id_lang = 1)
left join ps_attribute_lang pal on (pal.id_attribute = pac.id_attribute and pal.id_lang = 1)
GROUP BY od.product_id, od.product_attribute_id
ORDER BY product_quantity DESC


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More