Minor fixes to sql syntax