编写SQL查询以列出未提交任何所需评估的受训人员的所有培训生,姓名和电子邮件。
我的尝试:
SELECT TraineeId
, fname
, lname
, e-mail
FROM Trainee T
, assessment A
, submissions S
WHERE NOT EXISTS (A.assessmentId = S.assessmentId AND A.courseId = S.courseId)
AND T.traineeId = S.traineeId;
我不太确定这个问题。该代码试图找到两个表之间的交集。
此外,创建一个查询,以便为迟到的提交扣除5%
注意:这是来自练习考试,没有解决方案;这不是功课。
感谢您的帮助。
答案 0 :(得分:0)
可以解决您的问题
SELECT
T.TraineeId, T.fname, T.lname, T.e-mail
FROM
Trainee T,
join
submissions S
on
T.TraineeID = S.TraineeID
join
assessment A
on
S.AssessmentId=A.AssessmentId
WHERE condition
答案 1 :(得分:0)
SELECT `TraineeId`, `fName`, `lName`, `email`
FROM trainee T
WHERE TraineeId NOT IN (
SELECT S.TraineeId
FROM submissions S, assessment A
WHERE A.assessmentId = S.assessmentId
AND A.courseId = S.courseId
AND A.submissionDeadline >= S.submissionDate)