如何根据表C中的条件将表A中的记录插入表B.
表A:
ID Name DateFrom DateTo
1 Alex 22-7-2015 26-7-2015
2 Alice 21-8-2015 25-8-2015
表C:
ID Quarter DateFrom DateTo
1 Quater 1 1-7-2015 31-7-2015
2 Quater 2 1-8-2015 31-8-2015
如果表A中的记录在表C中的日期范围之间,它将插入到新的表B中.
赎回是表B.
insert into redemption(staffID,staffName,department,pointsAccumulated,referrerID)
select referrerStaffID,referrerName,referrerDepartment,SUM(points),activeDirectoryID
FROM referral
WHERE NOT EXISTS (select * from redemption1 where referrerID=activeDirectoryID) group by activeDirectoryID;