Given the following query, how do I return the p_name with the most transactions? And similarly, how do I return the t_amount with the most transactions. I'd like to do it all in this one query of course.
SELECT t.*, p.*
FROM transactions t
LEFT JOIN partners p ON p.id=t.partner_id
which can return something like:
t_amount t_platform t_user p_id p_name
100.00 windows 122 20 simmons
200.00 windows 211 20 simmons
100.00 mac 200 18 smith
100.00 linux 190 20 simmons
100.00 mac 100 18 smith
So given that result set, I'd get back best_partner = simmons and also best_amount = 100.00
Thanks!