move from r to sql