So imagine I have a result set that looks something like this:
+----+------------+------------+
| Id | Date_One | Date_Two |
+----+------------+------------+
| 1 | 2022-05-12 | null |
| 2 | 2022-05-13 | 2022-05-11 |
| 3 | null | 2022-05-14 |
+----+------------+------------+
I would like to order the result based on earliest date first, regardless of column. Each row will have either Date_One or Date_Two populated. They will never both be null.
So the result for the above result set would be:
+----+------------+------------+
| Id | Date_One | Date_Two |
+----+------------+------------+
| 2 | 2022-05-13 | 2022-05-11 |
| 1 | 2022-05-12 | null |
| 3 | null | 2022-05-14 |
+----+------------+------------+
(Since Id 2 has Date_Two earlier than Id 1's Date_One).
I'm not sure how I would create my ORDER BY clause. My naive solution was to use COALESCE, but that wouldn't work for ID 2 in my example.