MAX()
MySQL Function: MAX()
Max amount of the data
SELECT
*
FROM
payments
WHERE
amount = (
SELECT
MAX(amount)
FROM
payments
);
SELECT
*
FROM
payments
ORDER BY
amount DESC
LIMIT 1;
Latest date for each person
SELECT
a.*
FROM
messages a
INNER JOIN (
SELECT name, max(other_col) AS other_col
FROM messages
GROUP BY name
) AS b
ON a.name = b.name
AND a.other_col = b.other_col