surprisingly, to find the min date per company, which is a super basic query, on mysql you need to do a complicated query.
SELECT a.id, a.company, a.email, a.custom_last_email FROM leads a INNER JOIN ( SELECT company, MIN(custom_last_email) mindate FROM leads GROUP BY company ) b ON a.custom_last_email = b.mindate and a.company = b.company GROUP BY a.company