How to get a value from previous record in a query
The Following query has brought records for John’s math record from student’s score table named MyTable
Query1
ID ---- Studentname ------ subject ---- score ---- month
.
12 ----John ---- ---- ---- math ---- ---- 17 ---- ---- January
18 ---- John ---- ---- ---- math ---- ---- 12 ---- ---- February
54 ---- John ---- ---- ---- math ---- ---- 19 ---- ---- April
71 ---- John ---- ---- ----math ---- ---- 7 ---- -- ---- Jun
92 ---- John ---- ---- ---- math ---- ----15 ------ ---- Sep
How can we get the score from previous exam?
Query2
ID ---- Studentname ---- subject ---- score ------ month ----previous_Score
.
12 ---- ----John ---- ---- --- math ---- 17 ---- ---- January ---- ---- 17 (or null)
18 ---- ---- John ---- ------- math ---- 12 -- ------ February --- ----- 17
54 ---- ---- John ---- --- ---- math ---- 19 -- ------ April ---- ------- 12
71 ---- ---- John ---- --- ---- math ---- 7 ---- ---- Jun ---- ---------- 19
92 ---- ---- John ---- --- ----math ---- 15 ---- ---- Sep ---- ---- ------ 7
I put the dashes just to better picture the fields.
Thank you
The Following query has brought records for John’s math record from student’s score table named MyTable
Query1
ID ---- Studentname ------ subject ---- score ---- month
.
12 ----John ---- ---- ---- math ---- ---- 17 ---- ---- January
18 ---- John ---- ---- ---- math ---- ---- 12 ---- ---- February
54 ---- John ---- ---- ---- math ---- ---- 19 ---- ---- April
71 ---- John ---- ---- ----math ---- ---- 7 ---- -- ---- Jun
92 ---- John ---- ---- ---- math ---- ----15 ------ ---- Sep
How can we get the score from previous exam?
Query2
ID ---- Studentname ---- subject ---- score ------ month ----previous_Score
.
12 ---- ----John ---- ---- --- math ---- 17 ---- ---- January ---- ---- 17 (or null)
18 ---- ---- John ---- ------- math ---- 12 -- ------ February --- ----- 17
54 ---- ---- John ---- --- ---- math ---- 19 -- ------ April ---- ------- 12
71 ---- ---- John ---- --- ---- math ---- 7 ---- ---- Jun ---- ---------- 19
92 ---- ---- John ---- --- ----math ---- 15 ---- ---- Sep ---- ---- ------ 7
I put the dashes just to better picture the fields.
Thank you