i have a table with userIds and some dates like this : -
| userId | dates |
| 1 | 2021-06-20 00:00:00|
| 1 | 2021-06-24 00:00:00|
| 2 | 2021-06-25 00:00:00|
| 2 | 2021-06-28 00:00:00|
| 2 | 2021-06-30 00:00:00|
| 3 | 2021-06-22 00:00:00|
| 3 | 2021-06-24 00:00:00|
| 3 | 2021-06-27 00:00:00|
I want to find first date for every user with userId that doesn't exist:-
expected output: -
| userId | dates |
| 1 | 2021-06-21 00:00:00|
| 2 | 2021-06-26 00:00:00|
| 3 | 2021-06-23 00:00:00|
I'm using postgres, can someone help as the data is pretty large, 4m+.