Skip to content
Advertisement

Continuous subset and ranking using sql

I have a dataset like below:
enter image description here

Now, I need the output as below:

For this purpose, I wrote a query but it is not giving me the desired sequence. My query is as below:

It generates the output as below:
enter image description here

But in the rank section I need something as below:
enter image description here

So, what exactly am I doing wrong here?

Here are the PostgresSQL DDLs:

Advertisement

Answer

Try this query:

->Fiddle

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