Skip to content
Advertisement

How to create Seq No for repeating rows from Select query?

I have a table called Test with some repeating rows with column called Col1. The Sequence will reset to 0 when hit A. I want to create a sequence no as Result something like below:

Result:

— query I have used

Only will generate:

Result:

Advertisement

Answer

Here, col1 is ordered like this in your question so there must be some criteria based on which this order is defined. Lets say the criteria is PK column.

So I am considering that there is column PK based on which col1 is ordered as seen in your question.

You can use following query:

DB<>FIDDLE DEMO

Cheers!!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement