Minor changes to sql