Answer the question
In order to leave comments, you need to log in
SQL query increment inside group?
Not a newbie, like, but this is the first time I've come across this.
The following data is given:
num | txt
1 | q
1 | w
1 | e
2 | a
2 | s
2 | d
3 | z
3 | x
num | txt
1 | q
2 | w
3 | e
1 | a
2 | s
3 | d
1 | z
2 | x
Answer the question
In order to leave comments, you need to log in
select num, txt, row_number() over (partition by num order by num) as rn from tab;
I would like to get a universal sql queryYou don't have a key. If you use num+txt for it, then when you change it, you will get either a change prohibition (error) or an indeterminate record (error).
ID is also presentBuild a cursor. Define a variable and start counting rows in it from 1 until num changes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question