Editing to make it better: Let's say I have login events with 2 important fields: past_deviceid, new_deviceid I want to check if the new_deviceid was assigned to a different user in the past, for that I need to compare the value of the field to the past_deviceid field of past events and I'm kinda stuck here In login events where the user uses their usual device, there'll be only 1 field called past_deviceid, we get the new_deviceid field only when there's a login with a new device In the end I want to have a table that shows the new_deviceid by all the users that hold/held it where there's more than 1 user Example: events with only 1 device: User: Josh old_Device: iPhone12348 --------------------------- User: John old_Device: samsung165 ---------------------------- case where there's a new device: User: Jane old_Device: iPhone17778 new_Device: samsung165 I want to have the following table, I guess the stats command fits here: DeviceID User samsung165 Jane John
... View more