SQL Select max date from 2 columns

Viewed 27

In my case i have like this sample:

id date1 date2
1 01-01-2022 01-01-2022
1 07-01-2022 01-01-2022
1 07-01-2022 02-01-2022
2 02-01-2022 11-01-2022
2 09-01-2022 12-01-2022
2 10-01-2022 13-01-2022
3 01-01-2022 01-01-2022
3 01-01-2022 05-01-2022
3 01-01-2022 02-01-2022

I want this output: choose the max date1 and if there are multiple max date1 with the same value then we will choose the max date2

id date1 date2
1 07-01-2022 02-01-2022
2 10-01-2022 13-01-2022
3 01-01-2022 05-01-2022

Any solution please with SQL ? Thanks

0 Answers
Related