无法获得批发价格和客户名称SQL Manager Prestashop

时间:2017-09-05 01:45:17

标签: mysql sql prestashop prestashop-1.6 prestashop-1.5

我正在努力为这个"产品销售"提供批发价格和客户名称。报告,但我不明白为什么我没有得到结果。 此SQL显示结果直到"支付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;

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

1 个答案:

答案 0 :(得分:1)

请尝试:

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;