How to get the previous row from a defined row.
For example you have a student table and you would like to see the record of a student who have previous record row from student id 12.
For this the query is:
DECLARE @intStudentID int=12
SELECT top 1 * from STUDENT A WHERE A. intStudentID < @intStudentID order by 1 desc
For this the query is:
DECLARE @intStudentID int=12
SELECT top 1 * from STUDENT A WHERE A. intStudentID < @intStudentID order by 1 desc
Comments
Post a Comment