TSQL compare values of rows cells without knowing their value

by Anna Stepanyan   Last Updated August 18, 2018 12:06 PM

I have a table which contains just two columns, it is X and Y type of int.

Column | Type

   X   | int

   Y   | int

This are coordinates. I should write a procedure now while I have no access to the information contained in the columns now, so I can't select x where y = 'somevalue' cause I don't have information both about Xs and Ys. Now I have to compare 2 consequential rows, I mean the x of the first row with the x of second row like x1 with x2

x1 - y1

x2 - y2

x3 - x4

....

So I wonder what are the ways to select cells of two consequential rows in order to compare them.

Tags : t-sql


Related Questions