我在 SQL 中找到了 3 table 个丢失的数据

I have 3 table missing data find in SQL

enter image description here

select * from TimeSheet
WeekID  StudentID   Hours
1        1           40
2        1           40
4        1           40
1        2           40
2        2           40
3        2           4
4        2           40
1        4           40
3        3           40
select * from Week
WeekID
1
2
3
4
select * from Student
StudentID   StudentName
1             ABC
2             XYZ
3             ASD
4             QWE

加入后我得到了这些结果。

如果有这个数据使用三个表

select TS.WeekID
     , TS.StudentID
     , TS.[Hours]
     , SS.StudentID
     , WW.WeekID
FROM TimeSheet TS
left JOIN Student SS ON SS.StudentID = TS.StudentID
left JOIN [Week] WW ON WW.WeekID = TS.WeekID 
 WeekID StudentID   Hours   StudentID   WeekID
  1      1          40        1          1
  2      1          40        1          2
  4      1          40        1          4
  1      2          40        2          1
  2      2          40        2          2
  3      2          4         2          3
  4      2          40        2          4
  3      3          40        3          3
  1      4          40        4          1


期望结果是...

WeekID  StudentID   Hours   StudentID   WeekID

3        1          40          1       2
1        3          40          3       3
2        3          40          3       3
4        3          40          3       3
2        4          40          4       1
3        4          40          4       1
4        4          40          4       1

我想得到例如:

请帮帮我。

如果交叉连接 WeekStudent 表以获得所有组合,然后使用 not exists 确定不存在 TimeSheet 记录的位置。

select W.WeekID, S.StudentID
from [Week] W
cross join Student S
where not exists (select 1 from TimeSheet T where T.StudentID = S.StudentID and T.WeekID = W.WeekID);