I need to get the last rows with a unique value from my mysql table. A simple table layout is a timestamp (now ()) and a username column. The table gets new data a couple of times per second, and I need the last row, where the username is unique.
SELECT MAX(timestamp) as timestamp, username
FROM bla
WHERE timestamp < (now() - interval 30 minute)
GROUP BY username
ORDER BY timestamp DESC
This query does not seem to return the last values, perhaps because the group is doing something I don't want ...
source
share