# MIGRATION LAYOVERS

WEEKLY QUACK CHALLENGE! · challenge 4 · hard · 5 guesses

> Chief Migration Officer Gadwall slaps a map on the wall. "Every year these ducks fly halfway across the continent and everybody cheers the starting pond and the finishing pond. Nobody asks about the middle! But I've been watching the flight logs, Duckbert — one pond keeps showing up as a pass-through stop again and again and again. It's not where they take off. It's not where they land for good. It's the pond they stop at, rest their wings, and then leave. Find me that layover hotspot or you're cleaning flight feathers until next migration season!"

## Task

On a duck’s journey, a layover is a pond it flies into and later flies out of again — never its starting pond or its final destination. Return the name of the pond used as a layover the most times across all journeys; on a tie, the alphabetically first. You will be working with the `flights` and `ponds` tables.

## Tables

### `flights` (17 rows)

| column | type |
| --- | --- |
| flight_id | INTEGER |
| duck_id | INTEGER |
| from_pond | INTEGER |
| to_pond | INTEGER |
| depart | TIMESTAMP |
| arrive | TIMESTAMP |

### `ponds` (6 rows)

| column | type |
| --- | --- |
| pond_id | INTEGER |
| name | VARCHAR |

## Data

The tables live in a DuckDB database: https://dbquacks.com/data/databases/weekly_202630_04_layovers.duckdb

To query it outside the browser, attach it read-only:

```sql
ATTACH 'https://dbquacks.com/data/databases/weekly_202630_04_layovers.duckdb' AS db (READ_ONLY);
USE db;
```

Play it in the browser: https://dbquacks.com/challenges/weekly/4

## Answer

The expected answer is not published. Submit on the page to have it checked.
