So i have a table like this, but there are around 3500 records that is updated weekly:
OID UNIQUEID RTYPE TIME OTHER
1 ABC_20170215 SENT 12:30 item1
2 ABC_20170215 RECEIVED 12:29
3 ABC_20170215 SENT 12:35 item4
So what I am trying to do is if UNIQUEID is a duplicate and RTYPE is different, I need to merge the rows of that pair. If there are 3 like above, I need to merge the pair that are closest in time, so the resulting table would look like below
OID UNIQUEID RTYPE TIME OTHER
1 ABC_20170215 <whatever> <whatever> item1
3 ABC_20170215 <whatever> <whatever> item4
The rtype and time field dont really matter too much because those fields can be dropped if needed or they can be calculated, doesn't matter. Hopefully someone has done this type of thing before and has some sample code on getting this accomplished.
this is not the same as posted before!!! I am not deleting duplicates, I am merging them based on pairs comparison and time difference closest to 0.
SO what I need is if
UNIQUEID = UNIQUEID <- duplicates/matches
and
RTYPE != RTYPE <- different
if there is more than one pair possibility, then subtract the time between the two, so for my example table
Pair1.Time - Pair1.Time = 1 (12.30-12.29)
Pair2.Time - Pair2.Time = 6 (12.29-12.35)
and whichever is closest to 0, merge that pair, but there could honestly be an infinite set of pair possibilities