Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

YoY Research Grants by Department

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

Your question is YoY Research Grants by Department. 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 Chicago research administration team needs to monitor annual awarded research funding by department. Write a PostgreSQL query that calculates year-over-year growth for every department and fiscal year with at least one awarded grant.

Requirements

  1. Extract the calendar year from award_date and aggregate awarded grant amounts by department and year.
  2. Compare each year's total with the same department's previous calendar year using a LEFT JOIN.
  3. Return NULL for growth when no prior-year total exists or when the prior-year total is zero.
  4. Report growth as a percentage rounded to two decimal places, ordered by department and year.

Schema

departments
ColumnTypeDescription
department_idPKINTEGERUnique department identifier
department_nameVARCHAR(100)Department name
school_nameVARCHAR(100)Associated school or division
research_grants
ColumnTypeDescription
grant_idPKINTEGERUnique grant identifier
department_idINTEGERDepartment associated with the grant
award_dateDATEDate the grant was awarded
amountNUMERIC(12,2)Grant funding amount
grant_statusVARCHAR(20)Current grant status
Tablesdepartmentsresearch_grants
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results