fixes to sql query