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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
IG Reels Posting Span
00:00
5 left

IG Reels Posting Span

EasySQL · PostgreSQL

Problem

On Instagram Reels, the growth team wants to understand posting consistency for active creators in the AARRR activation stage. Write a SQL query to find, for each user who posted at least 2 times in 2024, the number of days between their first and last post in 2024.

Requirements

  1. Use only posts created in calendar year 2024.
  2. Return one row per user with at least 2 posts in 2024.
  3. Output the user's user_id, first_post_date, last_post_date, and days_between_posts.
  4. Calculate days_between_posts as the difference in days between the first and last 2024 post.
  5. Order results by days_between_posts descending, then user_id ascending.

Schema

ig_posts
ColumnTypeDescription
post_idPKINTUnique post identifier
user_idINTInstagram user identifier
post_surfaceVARCHAR(50)Surface where the post was created, such as reels or fb_groups
created_atTIMESTAMPTimestamp when the post was created
caption_textTEXTOptional post caption
Tablesig_posts
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the one table are in the Question tab.

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.