Move last from querying to Database Statements