Got a scenario where we need to assign sequence to records based on its occurence and timestamp. I am not able to get it just with FIRST_VALUE and not sure if we need to do a self join on this.
Here is a simple case made:
I have a table with columns PName, PSeqNo, PTimestamp (image attached). We need to generate a new sequence number (called PDerivedSeqNo) based on the occurence of Name. If the subsequent entry of PName is after its last occurence without having any other PName between them then the two entries are sequenced same. If we have a new PName entry in between the similar names then the sequence should be incremented by 1.
Solved! Go to Solution.