I created a table "Test"
create table test
(
id int identity(1,1) not null,
correlation int,
data varchar(max)
)
Below are data of the table
insert into test(correlation,data) values(1,'x0')
insert into test(correlation,data) values(1,'x1')
insert into test(correlation,data) values(2,'z1')
insert into test(correlation,data) values(2,'z2')
insert into test(correlation,data) values(3,'a')
insert into test(correlation,data) values(4,'b')
insert into test(correlation,data) values(5,'c')
I need to display data on the web page and to connect table to itself on correlation and to do paging
For example if I have two records with the same correlation (1) I need to display two rows as one row with the data as Current Data and Previous Data. In example below current data will be x1 and previous will be x0.
Before
Correlation Data
1 x0
1 x1
After
Correlation Previous Data Current Data
1 xo x1
If correlation has only one row , than previous correlation in result will be null.
Currenly I did paging in Linq and it's working but I am afraid that in future it will cost performance problem.
Can sameone can help me with SQL .
Is there other good solution for this problem.