AnalystPath

Average Reviewer Tenure per Grant

SQLEasyJunior level~15 min

Problem

Table: `assignment`

| Column Name | Type |
|---|---|
| grant_id | int |
| reviewer_id | int |

`(grant_id, reviewer_id)` is the primary key. Each row says a reviewer is assigned to a grant proposal.

Table: `reviewer`

| Column Name | Type |
|---|---|
| reviewer_id | int |
| full_name | varchar |
| tenure_years | int |

`reviewer_id` is the primary key; `tenure_years` is never NULL.

For each grant, report the average `tenure_years` across its assigned reviewers, rounded to 2 decimal places, under the alias `avg_tenure`. Return the result in any order.

Tables

Example rows — the live problem includes the full dataset.

assignment
grant_idreviewer_id
11
12
13
reviewer
reviewer_idfull_nametenure_years
1Mara Voss3
2Theo Lin2
3Sana Roy1

Expected output

Your answer should return 2 rows with the columns grant_id, avg_tenure.

Starter code (SQL)

SELECT *
FROM assignment;

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

Related SQL questions