task Recursive CTEs · hard
Fork families
For original repositories (not forks) that have at least one fork, return repository_id, forks (descendants at any generation) and generations (deepest level).
what to return
- Columns
repository_idforksgenerationsin this order- Rows
- 25 rows · any order
- Skill
- Measure reach and depth in a parent–child graph. Refresher: Recursive CTEs →
expected result
Your query should return exactly these columns and values. Run it and compare.
expected result25 rows · any order
| repository_id | forks | generations |
|---|---|---|
| 3 | 1 | 1 |
| 14 | 1 | 1 |
| 23 | 1 | 1 |
first 3 of 25 rows
data you can query
Developer Platform dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.
repositories9 columns · 512 rows
| repository_idnumber · unique id | organization_idnumber · links to organizations | owning_team_idnumber · links to teams | repo_nametext | primary_languagetext | visibilitytext | created_atdate & time | archived_attext | forked_from_repository_idnumber · links to repositories |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | notifier-catalog | Python | private | 2022-06-01 00:00:00 | NULL | NULL |
| 2 | 1 | 2 | billing-metrics | C# | internal | 2022-06-08 00:00:00 | NULL | NULL |
| 3 | 1 | 4 | catalog-cli | Go | private | 2022-07-23 00:00:00 | NULL | NULL |
| 4 | 1 | 4 | catalog-cli-fork | Python | internal | 2022-07-21 00:00:00 | NULL | 3 |
| 5 | 1 | 5 | cli-metrics | Go | private | 2023-07-18 00:00:00 | NULL | NULL |
| 6 | 1 | 5 | web-infra | Swift | internal | 2023-01-21 00:00:00 | NULL | NULL |
- repository_idnumber · unique id
- 1
- organization_idnumber · links to organizations
- 1
- owning_team_idnumber · links to teams
- 1
- repo_nametext
- notifier-catalog
- primary_languagetext
- Python
- visibilitytext
- private
- created_atdate & time
- 2022-06-01 00:00:00
- archived_attext
- NULL
- forked_from_repository_idnumber · links to repositories
- NULL
- repository_idnumber · unique id
- 2
- organization_idnumber · links to organizations
- 1
- owning_team_idnumber · links to teams
- 2
- repo_nametext
- billing-metrics
- primary_languagetext
- C#
- visibilitytext
- internal
- created_atdate & time
- 2022-06-08 00:00:00
- archived_attext
- NULL
- forked_from_repository_idnumber · links to repositories
- NULL
- repository_idnumber · unique id
- 3
- organization_idnumber · links to organizations
- 1
- owning_team_idnumber · links to teams
- 4
- repo_nametext
- catalog-cli
- primary_languagetext
- Go
- visibilitytext
- private
- created_atdate & time
- 2022-07-23 00:00:00
- archived_attext
- NULL
- forked_from_repository_idnumber · links to repositories
- NULL
- repository_idnumber · unique id
- 4
- organization_idnumber · links to organizations
- 1
- owning_team_idnumber · links to teams
- 4
- repo_nametext
- catalog-cli-fork
- primary_languagetext
- Python
- visibilitytext
- internal
- created_atdate & time
- 2022-07-21 00:00:00
- archived_attext
- NULL
- forked_from_repository_idnumber · links to repositories
- 3
- repository_idnumber · unique id
- 5
- organization_idnumber · links to organizations
- 1
- owning_team_idnumber · links to teams
- 5
- repo_nametext
- cli-metrics
- primary_languagetext
- Go
- visibilitytext
- private
- created_atdate & time
- 2023-07-18 00:00:00
- archived_attext
- NULL
- forked_from_repository_idnumber · links to repositories
- NULL
- repository_idnumber · unique id
- 6
- organization_idnumber · links to organizations
- 1
- owning_team_idnumber · links to teams
- 5
- repo_nametext
- web-infra
- primary_languagetext
- Swift
- visibilitytext
- internal
- created_atdate & time
- 2023-01-21 00:00:00
- archived_attext
- NULL
- forked_from_repository_idnumber · links to repositories
- NULL
first 6 of 512 rows · your queries use all of them
solution.sql
Hints and the answer are always available. Using them counts the question as solved with help.