I am trying to pull the wholesale price and the customer name for this "Products Sold" report, but I don't understand why I am not getting a result. This SQL shows results till "payment AS "Medio de Pago".
SELECT w.id_warehouse AS "Warehouse ID", w.name AS "Warehouse Name", o.id_order AS "Order ID", od.product_id AS "Product ID",od.product_attribute_id AS "Combination ID", od.product_name AS "Product Name", od.product_quantity AS Quantity, date_add AS "Order Date", id_customer AS "Customer ID", payment AS "Medio de Pago", p.wholesale_price AS "Costo de Ventas", c.firstname AS "Nombre"
FROM ps_order_detail od
INNER JOIN ps_orders o ON (o.id_order = od.id_order)
LEFT JOIN ps_warehouse w ON (w.id_warehouse = od.id_warehouse)
JOIN ps_product p ON (p.id_product = od.product_id)
JOIN ps_customer c ON (c.id_customer = o.id_customer)
WHERE o.date_add > DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 30 DAY),'%Y-%m-%d')
ORDER BY date_add ASC, o.id_order ASC, w.id_warehouse ASC;
Thanks a lot for the help. I am really unsure what is not working.
Please try with:
SELECT w.id_warehouse AS "Warehouse ID", w.name AS "Warehouse Name", o.id_order AS "Order ID", od.product_id AS "Product ID",od.product_attribute_id AS "Combination ID", od.product_name AS "Product Name", od.product_quantity AS Quantity, o.date_add AS "Order Date", c.id_customer AS "Customer ID", payment AS "Medio de Pago", p.wholesale_price AS "Costo de Ventas", c.firstname AS "Nombre"
FROM ps_order_detail od
INNER JOIN ps_orders o ON (o.id_order = od.id_order)
LEFT JOIN ps_warehouse w ON (w.id_warehouse = od.id_warehouse)
JOIN ps_product p ON (p.id_product = od.product_id)
JOIN ps_customer c ON (c.id_customer = o.id_customer)
WHERE o.date_add > DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 30 DAY),'%Y-%m-%d')
ORDER BY o.date_add ASC, o.id_order ASC, w.id_warehouse ASC;