runtime
130 / 139

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_idforksgenerations in 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_idforksgenerations
311
1411
2311

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 idorganization_idnumber · links to organizationsowning_team_idnumber · links to teamsrepo_nametextprimary_languagetextvisibilitytextcreated_atdate & timearchived_attextforked_from_repository_idnumber · links to repositories
111notifier-catalogPythonprivate2022-06-01 00:00:00NULLNULL
212billing-metricsC#internal2022-06-08 00:00:00NULLNULL
314catalog-cliGoprivate2022-07-23 00:00:00NULLNULL
414catalog-cli-forkPythoninternal2022-07-21 00:00:00NULL3
515cli-metricsGoprivate2023-07-18 00:00:00NULLNULL
615web-infraSwiftinternal2023-01-21 00:00:00NULLNULL
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.

Fork families — SQL practice · Runtime