无法获取批发价和客户名称 SQL Prestashop 经理

Unable to get the Wholesale price and Customer Name SQL Manager Prestashop

我正在尝试提取此 "Products Sold" 报告的批发价和客户名称,但我不明白为什么我没有得到结果。 此 SQL 显示 "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;

非常感谢您的帮助。我真的不确定什么不起作用。

请尝试:

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;