select NEWID(),AcademicYearNo,Semester,Grade,LessonName,[LessonNo],0,1,'{ExamTime}' from OpenLessonPlan where lessonsortno=1 and AcademicYearNo='{AcademicYearNo}' and Semester='{Semester}'
select NEWID(),AcademicYearNo,Semester,Grade,LessonName,[LessonNo],0,1,'{ExamTime}' from OpenLessonPlan where ExamType='1' and lessonsortno=1 and AcademicYearNo='{AcademicYearNo}' and Semester='{Semester}'
and [LessonNo] not in (select [LessonNo] from Exam_ExamLesson where AcademicYearNo='{AcademicYearNo}' and Semester='{Semester}' )
group by LessonNo,LessonName,AcademicYearNo,Semester,Grade