SQL Guru
asked on
SQL LEAD -Running total
Is there any better way to get the position value without creating temporary table?
Id value character_Len Position
1 ab 2 2
2 1 2 4
3 34 2 6
4 @ 1 7
5 00100 5 12
create table #temp2 (id int , [character] varchar(100), position int)
insert into #temp2(id,character,position)
select a.Id, a.item, sum(b.lens) -1 as position
from #t1 a cross join #t2 b
where b.Id <= a.Id
group by a.Id, a.item
order by sum(b.lens)
#t1 holds all information expect position column.
For which SQL Server version you need the solution?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.