Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Window Functions for Rolling Trends
00:00
5 left

Window Functions for Rolling Trends

MediumSQL · PostgreSQL

Problem

How would you use SQL window functions to compute rolling survey trends and rank regions by response rate at Ipsos?

Use the regions, survey_waves, and regional_survey_metrics tables for survey waves from January through April 2025. Calculate each region's rolling three-wave response rate and its overall response-rate rank.

Output

  1. One row per region and available survey wave.
  2. Columns: region_name, wave_month, rolling_response_rate, overall_response_rate, and region_rank.
  3. Include only waves in the requested period, order by wave_month ascending and region_name ascending, and assign equal ranks to tied response rates.

Schema

regions
ColumnTypeDescription
region_idPKINTUnique region identifier
region_nameVARCHAR(100)Ipsos reporting region name
survey_waves
ColumnTypeDescription
wave_idPKINTUnique survey wave identifier
survey_nameVARCHAR(150)Survey or study name
wave_monthDATEFirst day of the survey wave month
regional_survey_metrics
ColumnTypeDescription
metric_idPKINTUnique regional metric identifier
wave_idINTSurvey wave identifier
region_idINTRegion identifier
invited_countINTNumber of invited respondents
completed_countINTNumber of completed responses
Tablesregionssurvey_wavesregional_survey_metrics
Interviewer

Your question is Window Functions for Rolling Trends. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.