我需要知道,我如何在飞行中做到这一点,
例如,我的客户处于不同的截止日期状态,我想选择 MAX(最近的截止日期)ON LEFT JOIN,当它加入两个表时,它选择了最旧的截止日期,这不是我想要的..
SELECT c.customerid, i.datedue
FROM customers c
LEFT JOIN invoice i
ON i.customerid = c.customerid
WHERE i.datedue <= UNIX_TIMESTAMP()
AND c.status!='d'
GROUP BY i.customerid
ORDER BY i.datedue DESC
LIMIT 0, 1000