我有這個查詢,讓我回來多個結果。我想編輯它,這樣它只會給我一個結果,每個o.Customer_ID,然後這就是今天最接近o.OrderPlaceServerTime的訂單。MySQL查詢。給最接近的日期至當前
這裏的查詢我:
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'
什麼會,我需要改變,以實現這一目標?
請問 '最接近的日期' 是'MAX(OrderPlaceServerTime)'? – Kermit
是的,這是正確的。 – Monty