Reputation: 91
I have a problem in SQL postgres. I'm starting with this kind of table:
As you can see, I have some rows with same year, month, day, which can often occur. For each of them the columns count and dmg are different. I want to associate for each of these rows with same year,month,day but different count and dmg, the same number id, as you can see in the next img:
wish someone could help me. thanks in advance!
Upvotes: 0
Views: 39
Reputation: 1270463
You can use dense_rank()
:
select dense_rank() over (order by year, month, day) as id,
t.*
from t;
Upvotes: 2