我正在使用 Mysql 5.1,并且有这个查询,有没有办法不使用子查询并完成相同的结果?
SELECT oref.affiliate_id, ROUND(sum( oph.amount ) * 0.10 ,2) AS tsum
FROM operators_referer AS oref
LEFT JOIN operators_payments_history AS oph
ON oref.operator_id = oph.operator_id
WHERE oref.affiliate_id = 28221
AND
(
oph.date_paid >
(
SELECT MAX(aph.date_paid)
FROM affiliates_payments_history AS aph
WHERE aph.operator_id = oref.affiliate_id
)
OR
(
SELECT MAX(aph.date_paid)
FROM affiliates_payments_history AS aph
WHERE aph.operator_id = oref.affiliate_id
)
is NULL
)