I have a simple select statement. I want to add a temporary column which will number the rows in my result set. I tried this -
declare @num int
set @num = 0;
select t.A, t.B, t.C, (@count + 1) as number
from tableZ as t
It assigns the 1 to all rows. I tried @count = @count + 1 and it did not work.
How do I do this thing in a simple manner ?
thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…