Create SQL to R