I am trying to write a query which would allow me to add two columns and then shift the number to the row below. An example will better explain what I am doing.
I thought this would work but it just is adding the two columns next to each other. Any thoughts??
left join table1 b ON a.rowno-1 = b.rowno
My brain refuses to function normally at this time, so I couldn't find a way to do it with a SELECT. But since I did it with an UPDATE, I really can't see how it can be hard to do with a single SELECT. The problem for me is that it's not possible to do @i = @i + t2.OriginalValue and data retrieval in the same SELECT.
Anyway, here's my UPDATE that does what you're looking for.
select rowno,CumulativeValue,OriginalValue from @t
answered Oct 31, 2011 at 01:10 PM
answered Nov 01, 2011 at 07:50 AM
Kev Riley ♦♦