Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Running Average With Window Functions

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

Your question is Running Average With Window Functions. 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

Hinge's analytics team wants to monitor engagement with the Discover experience. Write a PostgreSQL query that calculates each user's rolling average of daily interactions over the preceding 30 calendar days, including the current interaction date.

Use 2026-03-01 as the report date. Only interactions from 2026-02-01 through 2026-03-01, inclusive, should be considered.

Requirements

  1. Aggregate multiple interactions for the same user on the same date into daily_interactions.
  2. Calculate a 30-day rolling average per user with a window function.
  3. Include only users with at least one interaction in the reporting period.
  4. Return results ordered by user_id and interaction_date.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Hinge user identifier
display_nameVARCHAR(100)User display name
interactions
ColumnTypeDescription
interaction_idPKINTUnique interaction event identifier
user_idINTUser associated with the interaction
interaction_typeVARCHAR(50)Type of Hinge interaction
occurred_atTIMESTAMPTimestamp when the interaction occurred
Tablesusersinteractions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results