Skip to content
Advertisement

How to order occurrences counting from 1 to n occurrences

I have a table that contains several columns, but for the task, the important ones are id end created_date, where id can repeat.

Sample data:

I need to write a query that creates a new column that enumerate the occurrences of each id, ordered by the ascending created_date. The output must be something like the following:

What query would output this result table?

Advertisement

Answer

you can use window function

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