Hi i have problem with task i need to do. I have a table in SQL showing log of users (subscibers) with triggers that add TIMESTAMP, ACTION PERFORMED and NAME of the subscriber, looks something like this:
TABLE: audit_subscibers
| ID | Name | Action | Time |
|---|---|---|---|
| 0 | John | Insert a subscriber | 2020-1-1 |
| 1 | John | Deleted a subscriber | 2020-3-1 |
| 2 | Mark | Insert a subscriber | 2020-4-5 |
| 3 | Andrew | Insert a subscriber | 2020-5-1 |
| 4 | Andrew | Updated a subscriber | 2020-5-15 |
Now i need to create a VIEW that shows ONLY subscribers (name) that has been deleted with DELETE TIME and INSERTION TIME, to achieve something like this:
'John' was added (like every other member) but also has beed deleted, not touching members that has only INSERTED
| Name | Date added | Date deleted |
|---|---|---|
| John | 2020-1-1 | 2020-3-1 |
| some other | 2020-x-x | 2020-y-y |
How to achieve this , taking only subscibers that has >1 entries and also one entry must indicate that user has been DELETED :Deleted a subscriber , and combine RESULT i ONE ROW?
I have another similar task, but this time i must create view (based only on audit_subscibers table) i must show ONLY subscribers that STILL exist (take all subscrb. with "Insert a subscriber" but reject from result those who has more rows including "Deleted a subscriber"
I am relly aprecciate the answers...