【发布时间】:2012-11-15 03:05:48
【问题描述】:
有2个表TableA
StudentID MeetingID TeacherID Date
001 1002581 1056 10-12-2012
001 1006789 1056 10-13-2012
001 1006754 1058 10-13-1012
还有一张桌子B
StudentID MeetingID TeacherID Date Value
001 1002581 1056 10-12-201 15
001 1002856 1056 10-20-2012 21
条件是表 A 中特定学生教师会议的 max(date) 与表 B 中同一学生教师会议的 max(date) 匹配值。我希望看到结果集类似于
StudentID MeetingID TeacherID Date Value
001 1006789 1056 10-20-2012 21
我怎样才能达到上述结果集
【问题讨论】:
-
嗯,不太确定你在这里给出的结果集。您说您希望 tablea student-meeting-teacher 上的 max(date) 与 tableb student-meeting-teacher 上的 max(date) 匹配。当我查看您的结果时,应该不是值 21 记录,而是值 15 记录....
标签: sql-server tsql