I want to compute the difference between two dates and then select the maximum difference using SQL. If there is more than one maximum difference, I want to select one of them. Given the random nature of the max() function, how can I ensure the SQL will return the same row every time?
I am using PostgreSQL as the database.