#14 updated sql for moodle 2.7