insert into "B_Student_del" select s.* from "B_Student" s join "B_Class" cla on cla."ClassID"=s."ClassID" join "B_Grade" gra on gra."GradeID"=cla."GradeID" and gra."StudyYearID"=2019 join "B_School" sch on sch."SchoolID"=gra."SchoolID" and sch."SchoolID"=35; DELETE from "B_Student" where "StudentID" in (select s."StudentID" from "B_Student" s join "B_Class" cla on cla."ClassID"=s."ClassID" join "B_Grade" gra on gra."GradeID"=cla."GradeID" and gra."StudyYearID"=2019 join "B_School" sch on sch."SchoolID"=gra."SchoolID" and sch."SchoolID"=35) RETURNING *