我有一个查询可以获得在精确日期销售的sku_product产品
SELECT stock_products.`related_warehouse_position_id`, `product_code`, `EAN_CODE`, `custom_cart_picked_up`, `warehouse`, sum(`RemainingStock`), stock_products.`time_Picked_up`
FROM `product_warehouse_position`
INNER JOIN stock_products ON product_warehouse_position.id = stock_products.related_warehouse_position_id
WHERE stock_products.time_Picked_up < '2017-10-10'
GROUP BY product_code
HAVING SUM(RemainingStock) = 0
现在我已经尝试过这个查询,但结果是错误的。
我尝试制作子查询,但我需要获取一个位于stock_products表上的time_pickedUp。
SELECT `id` ,`product_code`, `EAN_CODE`, `custom_cart_picked_up`, `warehouse`, sum(`RemainingStock`)
FROM product_warehouse_position
WHERE product_code IN (
SELECT product_stock_sku, time_Picked_up
FROM `stock_products`
WHERE stock_products.time_Picked_up < '2017-05-01'
)
GROUP BY product_warehouse_position.product_code
HAVING SUM(product_warehouse_position.`RemainingStock`) = 0
此查询返回错误:
如何在不改变此查询结构的情况下解决此问题?
答案 0 :(得分:0)
如果您的查询正确,那么您唯一需要做的就是从内部查询中的select中删除列time_Picked_up
。您仍然可以在WHERE
子句中对该列进行过滤。