I have a table
id mid userid remarks 1 2 8 7 2 2 8 6 3 2 8
Try this:
SELECT MAX(id),mid,userid,remarks FROM sample WHERE id NOT IN ( SELECT MAX(id) FROM sample ) GROUP BY mid,userid,remarks
EDIT
See if this works
SQL FIDDLE DEMO