Skip to content
Advertisement

How to rank values in SQL for an existing and pre-arranged set

I will need the implementation in SQL only and not PL-SQL or any other programming method.

Advertisement

Answer

This is a gaps-and-islands problem. In this case, lag() and a cumulative sum does what you want:

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