I have an Iceberg table something like:
Columns: [custID,X, uniqueTransId ------]
[127, 2, a0, -----]
[127,2, a1, -----]
[127,3, a2, -----]
[127,4, a3, -----]
[127,5, a4, -----]
[128,6, a5, -----]
[129, 7, a6, -----]
[129, 8, a7, -----]
[130, 2, a8, -----]
[130, 2, a9, -----]
[Null, 3, a10, -----]
Result Columns: [custId, X, uniqueTransId, newField, ------]
[127, 2, a0, 2_3_4_5, -----]
[127, 2, a1, 2_3_4_5, ------]
[127, 3, a2, 2_4_5, ------]
[127, 4, a3, 2_3_5, ------]
[127, 5, a4, 2_3_4, ------]
[128, 6, a5, Null, ------]
[129, 7, a6, 8, ------]
[129, 8, a7, 7, ------]
[130, 2, a8, 2, ------]
[130, 2, a9, 2, ------]
[Null, 3, a10, Null, ------]
how can we achieve this?
This is kind of for same Customer ID, I need to put X of all instance other than the current one to a new column. For example: For custId 127, there are 4 rows and the Value of field X are 2, 3, 4, 5. For each row, i need the Value of field X of other transactions: For transaction a1, it will be 3,4 and 5. Similarly for transaction a2, it will be 2,4 and 5.
For custId 128, there are no matching rows where same custID is present, so there is no value for new Field and it should be set to Null in result.
May be it doesn't need a self join and some other query can do the work here, but with my limited understanding, it seems a self join problem.