I'm building a leaderboard and want to return a MIN() value - however, I also want another field which is on the same row as the min value.
I have this so far:
SELECT u.username, MIN(timer) AS intScore, l.hashtag
FROM users u
JOIN leaderboard l ON l.users_id = u.users_id
GROUP BY u.username
ORDER BY
intScore ASC
...this returns the correct MIN intScore, but not the correct hashtag.
The db looks liks this:
Leaderboard DB:
users_id, timer, hashtag
1, 10, TEST
2, 12, TEST
1, 20, TEST
3, 15, TEST
1, 5, LIVE
4, 20, LIVE
and I want the result to be:
users_id, timer, hashtag
1, 5, LIVE
2, 12, TEST
3, 15, TEST
4, 20, LIVE
Any help would be appreciated