# Above Their Generation

THE GREAT DUCK MIGRATION! · challenge 36 · medium

> Admiral Aqua strides in carrying a gilded chart of age-bracketed performance statistics. "Migration leadership rewards those who rise above their peers! Every athlete is born into an age bracket, and every bracket sets its own standard of excellence. I don't care how old a duck is - I care whether they outperform the others who share their years. Calculate each athlete's career average across all competitions, then weigh it against the combined average of every competition flown by ducks of the same age. The athletes who beat their own generation's average have proven they lead their bracket, and they will anchor our age-balanced command formations through the skies ahead. Sum the identification codes of every duck who outshines their age group!"

## Task

Return the sum of SSNs for all ducks whose career average score (the mean of all their own competition scores) is strictly higher than their age group's average score. Calculate an age group's average as the mean of every competition score recorded by all athletes of that age, including the duck's own competitions. Only include ducks who have at least one competition. You will be working with the `duck_athletes` and `performance_records` tables.

## Tables

### `performance_records` (800 rows)

| column | type |
| --- | --- |
| duck_id | BIGINT |
| sport | VARCHAR |
| score | DOUBLE |
| competition_date | DATE |

### `duck_athletes` (50 rows)

| column | type |
| --- | --- |
| id | BIGINT |
| ssn | BIGINT |
| name | VARCHAR |
| age | BIGINT |
| hometown | VARCHAR |

## Data

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

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

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

Play it in the browser: https://dbquacks.com/challenges/athletic/36

## Answer

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