mercredi 14 octobre 2015

Get the top ID in each group in SQL Server

i want to add a column that contains the first 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        1
Orange        1
Apple         5
Apple         5
Apple         5
Grapes        8
Grapes        8

Aucun commentaire:

Enregistrer un commentaire