次のような 2 つのテーブルがあります。
Table1
________
StudentNumbers ExamType
1234 1
2343 2
3345 5
3454 1
5465 2
...
Table2
________
StudentNumbers ExamType ExamDate School Area
1234 1 0825 warren ny
1234 1 0829 north nj
1233 2 0921 north nj
2343 1 0922 warren ny
2343 1 0925 north ny
...
特定の ExamType の Table1 のデータを使用して、Table2 から各学生の最大 ExamDate を見つける必要があります。私はこれまでこれを思いつきましたが、これは間違っているようです:
Select t2.StudentNumbers, t2.ExamType, max(t2.ExamDate), t2.School, t2.Area
from Table2 as t2
Join Table1 as t1 on
t1.StudentNumbers = t2.StudentNumbers
where t2.ExamType = 1
集計関数または group by 句のいずれにも含まれていないため、選択リストで無効としてエラーが発生しています
それは基本的に戻ってくるはずです:
StudentNumbers ExamType ExamDate School Area
1234 1 0829 north nj
2343 1 0925 north ny