Performance improvement: query to determine Course (All Years) information creating a temporary table when it doesn't need to.
Performance improvement: because we are deleting any rows with COURSEID=12 then the AND condition in the WHERE clause is unnecessary.
Performance enhancement: Missing indexes on tables.