I have an issue with an SQL Query I'm trying to build on Oracle DB. I need to find out cases where some records have been created before other records. it sounds simple, but i'm having issues with it, i cant tell why.
there's a table that contains user detailed events, called "USER_EVENTS". we found a certain bug that involves deletion of users, before they were activated. I want to get all the Users that had this bug, so if i look at the table i'll see something like this:
TABLE USER_EVENTS
ID EVENT_TYPE EVENT_DATE USER_ID
1 USER_DELETED 10/1/2019 5301
2 USER_ACTIVATED 9/1/2019 5301
3 USER_DELETED 5/1/2019 5302
4 USER_ACTIVATED 11/1/2019 5302
5 USER_DELETED 1/1/2019 5288
6 USER_DELETED 2/1/2019 5287
7 USER_CREATED 1/12/2018 5211
8 USER_NOTE 1/12/2018 5211
tried various queries i cant seem to match those two, i know its silly, i apologize.
looking at the table above, i want to get the USERIDs of those parcels that had the DELETED event before the ACTIVATED event. from the image, what i should get in return is "5302", which was deleted on the 5/1/2019 but activated on the 11/1/2019.
Thanks in advance!
P.S. - please dont get into a design issue with naming conventions or how to not have this bug etc', the above is just a general example.