我试图动态创建GroupID列。以下是我需要的样子。如何动态添加基于ParentJob的GroupID?
ParentJob ParentPart ParentDescription ParentCompleteDate GroupID
00000111 360120 4/1 Gal-Egg Food Color 2002-01-13 1
00000111 360120 4/1 Gal-Egg Food Color 2002-01-13 1
00000111 360120 4/1 Gal-Egg Food Color 2002-01-13 1
00000111 360120 4/1 Gal-Egg Food Color 2002-01-13 1
00000155 360120 4/1 Gal-Egg Food Color 2002-01-11 2
00000155 360120 4/1 Gal-Egg Food Color 2002-01-11 2
00000155 360120 4/1 Gal-Egg Food Color 2002-01-11 2
00000155 360120 4/1 Gal-Egg Food Color 2002-01-11 2
00000155 360120 4/1 Gal-Egg Food Color 2002-01-11 2
00000415 360120 4/1 Gal-Egg Food Color 2002-01-17 3
00000415 360120 4/1 Gal-Egg Food Color 2002-01-17 3
00000415 360120 4/1 Gal-Egg Food Color 2002-01-17 3
00000415 360120 4/1 Gal-Egg Food Color 2002-01-17 3
答案 0 :(得分:1)
select ..., dense_rank() over (order by ParentJob) as GroupId
from ....