add where to sql function