Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table like this: https://www.linkpicture.com/view.php?img=LPic623332bee51691149467893[^]

I want to automatically increment values in ID column where the difference between the previous value and other value is greater than 1.

So, I want like this: https://www.linkpicture.com/view.php?img=LPic6233322955e35422476399[^]

I tried a lot of things but couldn't accomplish what I exactly want. If you could help I would be grateful.

What I have tried:

I tried a lot things like lag(), sequence() and tried to do a update loop but it didn't work properly.

What I have tried:

I tried lag() to compute the differences in ID column then tried to make an update loop but it didn't work. I'm also a beginner in SQL, so I would be grateful for any help.
Posted
Updated 17-Mar-22 3:54am
v2
Comments
CHill60 17-Mar-22 9:56am    
The What I have tried: section is for you to post the code you tried.
"it didn't work properly" does not help us help you - tell us what happened.
Also, although I have fixed your links, I cannot see your tables because I am on my break at work and that site is blocked. Post the details in your question not on an external site
Edit: Also tell us which version of Oracle you are using - pre or post 12C?
CHill60 17-Mar-22 12:26pm    
I've finally been able to see those images and your logic is not at all clear. Why does it suddenly jump from 1006 to 1104 between row_index 6 and 7 ?
RedDk 17-Mar-22 13:56pm    
Perhpas it's because:
"It's 98 degrees ... in the shade". (reggae thump reggae thump)
CHill60 21-Mar-22 6:09am    
If you still need help with this you are going to have to provide the missing information

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900