Hello,
I have the following table / values:
Each imageid should have numerical pages starting at 1. I need to figure out a way to fill in the NULL values with 1+ the row above for EACH imageid. I'd like to end up with:
1,400,1
2,400,2
3,400,3
4,400,4
5,400,5
6,401,1
7,401,2
8,401,3
9,402,1
10,403,1
11,403,2
12,403,3
13,403,4
The data should be in order of the counter.
Each imageid starts with page 1.
This is SQL 2008.
Thanks so much for anyone's help!
I have the following table / values:
Code:
create table #temp (counter int, imageid int, newpage int)
insert into #temp values (1,400, 1)
insert into #temp values (2,400, NULL)
insert into #temp values (3,400, NULL)
insert into #temp values (4,400, NULL)
insert into #temp values (5,400, NULL)
insert into #temp values (6,401, 1)
insert into #temp values (7,401, NULL)
insert into #temp values (8,401, NULL)
insert into #temp values (9,402, 1)
insert into #temp values (10,403, 1)
insert into #temp values (11,403, NULL)
insert into #temp values (12,403, NULL)
insert into #temp values (13,403, NULL)
Each imageid should have numerical pages starting at 1. I need to figure out a way to fill in the NULL values with 1+ the row above for EACH imageid. I'd like to end up with:
1,400,1
2,400,2
3,400,3
4,400,4
5,400,5
6,401,1
7,401,2
8,401,3
9,402,1
10,403,1
11,403,2
12,403,3
13,403,4
The data should be in order of the counter.
Each imageid starts with page 1.
This is SQL 2008.
Thanks so much for anyone's help!