mercredi 14 octobre 2015

Add a column containing the id of the previous row in each group

I want to add a column that contains the id of the previous row in each group.

Sample:

Product       ID
Orange        1
Orange        2
Orange        3
Orange        4
Apple         5
Apple         6
Apple         7
Grapes        8
Grapes        9

Desired output:

Product       ID
Orange        1
Orange        1
Orange        2
Orange        3
Apple         5
Apple         5
Apple         6
Grapes        8
Grapes        8

Thank you!

Aucun commentaire:

Enregistrer un commentaire