Hello Experts,
For unknown reason, my OP was deleted.
I will post my question here again.
if I have a table below:
ID text term
1 ABCAB A
1 ABCAB B
I want to find the shortest distance between terms within same ID.
P.S same ID would have same text
For example: in the first record I have ID=1 text=ABC term=A , in the second record I have ID=1 text=ABC and term=B
I want to compare A with A, and A with B, and B with B for ID=1
the position of first A is 1, the second A has a position of 4 so the distance between A with A is 4-1=3
the position of first A is 1, the first B has a position=2, the second B has a position=5
so the distance between first A with first B is 2-1=1 and the distance between first A with second B is 5-1=4 so shortest distance between A with B is 1
the position of second A is 4, the position of first B is 2 so the distance is 2-4=-2,
the position of second A is 4, the position of second B is 5 so the distance is 5-4=1
etc.
so the final table should look like:
ID term1 term2 shortest distance
1 A A 1
1 A B 1
1 B B 3
... View more