Jump to content
info@kimukid.com

sql para productos vendidos

Recommended Posts

Hola

 

Necesito realizar una consulta para listar los productos vendidos en mi tienda de prestashop.

 

He probado con esta consulta, pero realmente no está funcionando bien, no muestra bien las cantidades.

 

SELECT P.reference as REFERENCIA, PL.`name` as Product_Name, COUNT(OD.id_order) as ordered_qty FROM ps_product P
LEFT JOIN ps_product_lang PL ON P.id_product = PL.id_product
LEFT JOIN ps_order_detail OD ON P.id_product = OD.product_id
LEFT JOIN ps_orders O ON O.id_order = OD.id_order
WHERE O.valid = 1
GROUP BY P.reference, PL.`name`
ORDER BY ordered_qty DESC
 
Necesitaría los datos en una tabla con las columnas: REFERENCIA, NOMBRE DEL PRODUCTO, PRECIO COSTE, PRECIO DE PVP Y CANTIDADES VENDIDAS
 
¿me ayudais a optimizar la sql?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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