问题
I'm having problem with GROUP BY. It returns the first entry it could find, but I would like it to return the last entry. Is that possible?
Here is my query (prepared query):
SELECT stamp_user, stamp_date, stamp_type
FROM rws_stamps
WHERE stamp_date >= ?
GROUP BY stamp_user
ORDER BY stamp_date DESC
My table looks like this:

What I want it to return is row 7 and 3, but i get 1 and 2.
回答1:
Try:
SELECT stamp_user, max(stamp_date), stamp_type
FROM rws_stamps
WHERE stamp_date >= ?
GROUP BY stamp_user, stamp_type
来源:https://stackoverflow.com/questions/3811750/get-the-last-entries-using-group-by