0

I have table with columns: ID, StartDate, EndDate If any two rows in this table have same ID and StartDate then I have to select only the one with the latest EndDate. How can I do this?

For example I have:

ID   | StartDate   | EndDate   
123  | 2020-01-01  | 2021-01-01
500  | 2020-01-01  | 2021-01-01
500  | 2021-03-10  | 2022-03-10
721  | 2021-03-10  | 2022-05-10
721  | 2021-06-17  | 2022-06-10
721  | 2021-06-17  | 2023-07-15

Result will be:

ID   | StartDate   | EndDate   
123  | 2020-01-01  | 2021-01-01
500  | 2020-01-01  | 2021-01-01
500  | 2021-03-10  | 2022-03-10
721  | 2021-03-10  | 2022-05-10
721  | 2021-06-17  | 2023-07-15

I have to delete only this row:

721  | 2021-06-17  | 2022-06-10
Baczek
  • 17
  • 5

0 Answers0