Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Year-over-Year Grant Funding Query

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Year-over-Year Grant Funding Query. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

The University of Colorado's research administration team needs an annual view of awarded grant funding by department. Write a PostgreSQL query that calculates year-over-year funding growth for each department and award year.

Requirements

  1. Include only grants with award_status = 'Awarded'.
  2. Aggregate awarded amounts by department and calendar year.
  3. Compare each year's total with the previous year's total using a join or equivalent SQL technique.
  4. Return NULL for growth when no prior-year total exists or the prior-year total is zero. Round percentage growth to two decimal places.

Schema

departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)University department name
grant_awards
ColumnTypeDescription
grant_idPKINTUnique grant award identifier
department_idINTDepartment receiving the award
award_dateDATEDate the grant was awarded
amountNUMERIC(12,2)Awarded funding amount
award_statusVARCHAR(20)Current award status
Tablesdepartmentsgrant_awards
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results