SQL function for determining latest price dates.