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

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