问题
I have a table that contains test marks from different terms, ca1_percent
, sa1_percent
, ca2_percent
and sa2_percent
. These 4 fields reside in the Results
table that contains results from the different terms.
I used a self-relationship linking using the matched field overall_percent_match
which is calculated using year & " " & subject & " " & _kf_studentID
. This relationship allows me to obtain the test results from past terms (of a year). For example, my term 3 results will contain results from term 1 and term 2 (of each subject). All works fine unless there is a new student who joins mid way of the year. If he joins in term 3, his ca2 results (done in term 3) will fall into his ca1_percent
column (which is supposed to contain term 1 results) like other records before him.
Image shows what I mean.

I could not figure out the solution. Can anyone help me?
This StackOverflow link contains more details of my work that was done related to this problem.
回答1:
The underlying problem, per your prior query, is that you're pulling the values through:
GetNthRecord(SA1_Results_Match::mark_percent,2)
This statement assumes the existence of an N=1, N=2 and N=3. To make this work properly you could do any of the following:
- Ensure that your Results table always has records from the prior semester, even if the student joins later in the semester. You could keep using GetNthRecord this way, but you will always need to ensure that the records are in order.
- Use an ExecuteSQL statement to gather only the correct semester's results for the correct summary field.
- Make four separate relationships, with separate Table Occurrences, to define ca1, sa1, ca2 and sa2 each separately. This looks like what you started out trying to do in the prior question.
来源:https://stackoverflow.com/questions/16852240/pushing-term-1-results-into-term-3-fields-for-new-students-joining-mid-year