我有这个查询,它给了我不止一个结果。我想对其进行编辑,以便每个 o.Customer_ID 只给我一个结果,然后使用 o.OrderPlaceServerTime 将其设为最接近今天的订单。
这是我的查询:
SELECT
o.Order_ID,
o.Customer_ID,
o.OrderPlaceServerTime,
o.CustomerOrderTotal
FROM
Orders o
LEFT JOIN Order_LineDetails oln
ON oln.Order_ID = o.Order_ID
WHERE
o.OrderPlaceServerTime >= '2012-09-01 00:00:00'
AND o.OrderPlaceServerTime <= '2012-12-01 00:00:00'
AND o.CustomerOrderTotal >= '50'
AND oln.Product_ID = '75'
我需要改变什么来实现这一点?