Minor fixes in sql querry records