0

使用下面的 SQL 语句,我可以根据需要获取有关学生的所有信息,除了一个问题是重复记录,而实际上最后一次输入的记录只需要每个学生。

学生证年级学期
20012-000001 20012-20013 1
20012-000001 20012-20013 2
20012-000001 20012-20013 3    
20012-000001 20012-20013 4        
20012-000001 20012-20013 5
    sqlSTR = "SELECT tblStudent.StudentID AS '??? ??????' , (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.GrandFatherName + ' ' + tblStudent.LastName) as '?????' ," & _
                "tblStudent.Gender as '?????', tblStudent.Citizenship as '???????', tblStudent.Type as '??? ?????'," & _
                "tblDepartment.DepartmentTitle as '?????', tblEnrolment.SchoolYear as '????? ????????',tblYearLevel.YearLevelTitle as '????? ???????',  " & _
                "'????'= CASE WHEN Len(tblGraduate.StudentID)<>12 THEN '???' ELSE ''End , " & _
                "'???? ???'= CASE WHEN Len(tblDropped.StudentID)<>12 THEN '???' ELSE ''End , " & _
                "'??????'= CASE WHEN tblStudent.Transferee ='True' THEN '???' ELSE ''End" & _
                " FROM tblDropped RIGHT JOIN " & _
                "(tblGraduate RIGHT JOIN " & _
                "(tblDepartment RIGHT JOIN " & _
                "(tblYearLevel RIGHT JOIN " & _
                "(tblSection RIGHT JOIN " & _
                "(tblStudent LEFT JOIN tblEnrolment " & _
                "ON tblStudent.StudentID = tblEnrolment.StudentID) " & _
                "ON tblSection.SectionID = tblEnrolment.SectionOfferingID) " & _
                "ON tblYearLevel.YearLevelID = tblEnrolment.YearLevelID) " & _
                "ON tblDepartment.DepartmentID = tblSection.DepartmentID) " & _
                "ON tblGraduate.StudentID = tblStudent.StudentID) " & _
                "ON tblDropped.StudentID = tblStudent.StudentID" & _
                " " & sFilter & _
                " ORDER BY tblStudent.StudentID DESC , tblYearLevel.YearLevelTitle ASC"
4

1 回答 1

0

将日期字段添加到包含记录并按最近过滤的表中。如果表已经有一个按日期包含 WHERE 子句?

如果我正确理解你的表格,最后一条记录总是在最后一个学期,如果你知道这个学期,只需为 Student_ID 做一个唯一的关键字

于 2012-07-28T22:43:52.783 回答