The problem with "last" is that it's not precise: unless you specifically select a sort order via an ORDER BY statement (or similar) SQL is at liberty to return rows in any order it finds convenient. Normally, that works out as "first in, first out", so a vanilla SELECT such as
SELECT * FROM MyTable
will return rows in the order that they were INSERTED.
But...it's not necessarily so! In order to be certain of your "last" row, you need to tell SQL explicitly what to order by.
So...add a "InsertDate" or "TimeStamp" column, and set it when you INSERT (the easiest way is to provide a DATETIME column and set it's DEFAULT to GETDATE() - then SQL will supply it for you without your external code having to change).
Then you have a column that can work with the GROUP BY clause to specify the "last" row in each group.