I've got this kind of statement:
declare @max int
@max = 1
SELECT @max, t1.col1, t1.col2
FROM table1 t1
this will give me results:
1 a a
1 b b
1 c c
and I would like to get this kind of result
1 a a
2 b b
3 c c
how can I achieve this result?
I've tried to do as follow:
@max = 1
SELECT @max, t1.col1, t1.col2
FROM table1 t1
WHERE @max = @max + 1
but with no success, can someone help me with it? thanks!
PS. I have to use @max as variable - I can not use Identity or AUTOINCREMENT column