私は 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
)