How can I update a column by getting a value from two-line on one table?
I test this
update [Exams_GAT_SAT]
set [SAT_improve] =(select ((select SAT_av from Exams_GAT_SAT where ayear = 1443)
-(select SAT_av from Exams_GAT_SAT where ayear = 1442))
from Exams_GAT_SAT where ayear = 1443)
An image has been attached showing what is required
Many thanks for helping me
1条答案
按热度按时间hfwmuf9z1#
Your example is wrong, but basically you can use LAG function to get the values from the previous row, then calculated the metric and after that update the table: