我正在尝试为此“产品售出”报告提取批发价格和客户名称,但我不明白为什么我没有得到结果。
此SQL会显示结果,直到“付款方式为“ 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;
非常感谢您的帮助。我真的不确定什么是行不通的。
最佳答案
请尝试:
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;
关于mysql - 无法获得批发价和客户名称SQL Manager Prestashop,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46045908/