I have created this function in postgres. train_route_timings(first_station, last_station, nth_route), this function required three parameters(first_station, last_station, n