Collaboration Reach of Each Researcher
Problem
Table: `coauthored`
| Column Name | Type |
|---|---|
| author_a | int |
| author_b | int |
Each row means researcher `author_a` co-wrote a paper with researcher `author_b`. The relationship is mutual but stored only once per pair, in either column order. A pair never repeats.
For every researcher who appears in the table, compute their *reach*: the number of distinct collaborators they have, expressed as a percentage of the total number of distinct researchers in the table. Round to 2 decimals and alias it `reach_pct`. Output the researcher id aliased `author_a` and `reach_pct`, ordered by `author_a`.
Tables
Example rows — the live problem includes the full dataset.
| author_a | author_b |
|---|---|
| 2 | 1 |
| 1 | 3 |
| 4 | 1 |
Expected output
Your answer should return 5 rows with the columns author_a, reach_pct.
Starter code (SQL)
SELECT *
FROM coauthored;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock