Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Use Window Functions

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

Your question is Use 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

Credit Karma’s Product Analytics team wants to monitor daily engagement with Credit Karma Credit Score. Write a PostgreSQL query that calculates the number of distinct active members viewing their score each day and a 3-day rolling average by state.

Requirements

  1. Join members to score_views using member_id.
  2. Include only active members in California, New York, or Texas who viewed credit_score from January 1 through January 3, 2026.
  3. Include dates with no qualifying views as zero-view days.
  4. Calculate the 3-day rolling average within each state, ordered by date.

Schema

members
ColumnTypeDescription
member_idPKINTUnique Credit Karma member identifier
stateVARCHAR(2)Two-letter member state code
membership_statusVARCHAR(20)Current membership status
score_views
ColumnTypeDescription
view_idPKINTUnique score-view event identifier
member_idINTMember associated with the event
viewed_atDATEDate on which the feature was viewed
event_typeVARCHAR(30)Product or feature viewed
Tablesmembersscore_views
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results