Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Average Swipes Last Month

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

Your question is Average Swipes Last Month. 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

Tinder's Data Science team wants to measure average user engagement during the most recently completed calendar month. Write a PostgreSQL query that calculates the average number of swipes per Tinder user during that month.

Requirements

  1. Include every user in the calculation, including users who made zero swipes during the month.
  2. Define the period as the previous calendar month, from its first instant through the first instant of the current month.
  3. Return one row containing the average swipe count per user, with the output column named average_swipes_per_user.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Tinder user identifier
display_nameVARCHAR(100)User's display name
swipes
ColumnTypeDescription
swipe_idPKINTUnique swipe event identifier
user_idINTUser who performed the swipe
target_user_idINTUser profile that was swiped on
swipe_directionVARCHAR(10)Swipe action, such as like or pass
swiped_atTIMESTAMPTimestamp when the swipe occurred
Tablesusersswipes
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results