updated query for calculating last and next pickup dates from Alex