I have a table like this:
| ID | OtherID | Date |
|---|---|---|
| 1 | z | 2022-09-19 |
| 1 | b | 2021-04-05 |
| 2 | e | 2022-04-05 |
| 3 | t | 2022-07-08 |
| 3 | z | 2021-03-02 |
I want a table like this:
| ID | OtherID | Date |
|---|---|---|
| 1 | z | 2022-09-19 |
| 2 | e | 2022-04-05 |
| 3 | t | 2022-07-08 |
That have distinct pairs consisted of ID-OtherID based on the Date values which are the most recent.
The problem I have now is the relationship between ID and OtherID is 1:M
I've looked at SELECT DISTINCT, GROUP BY, LAG but I couldn't figure it out. I'm sorry if this is a duplicate question. I couldn't find the right keywords to search for the answer.
Update: I use Postgres but would like to know other SQL as well.