Deb
Deb

Reputation: 13

Merge multiple rows for each ID so that the most information is collected

I have multiple rows for each ID, I don't want the most recent, I would like to merge these into the most complete entry for each ID. Each ID may have a different number of associated rows. I'd like to do this in either Alteryx or SQL but not sure at all where to begin.

for example:

row    ID                 ColA         ColB        ColC
 1    1234                             red         
 2    1234               purple        red        
 3    1234                                          blue

Desired result:

row    ID            ColA      ColB      ColC
1      1234        Purple      red       blue

Upvotes: 1

Views: 39

Answers (1)

John Cappelletti
John Cappelletti

Reputation: 81930

It looks like a simple aggregation should do the trick.

For Example

Select row = min(row)
      ,ID
      ,ColA = max(ColA)
      ,ColB = max(ColB) 
      ,ColC = max(ColC)
 From  YourTable
 Group By ID

Upvotes: 2

Related Questions