Median Hours Until a Marketplace Listing Gets Its First Message

Last updated: November 29, 2026

Quick Overview

Given Marketplace listings and buyer messages, write SQL that returns, per category for listings created last month, the share that received a buyer message within 7 days and the median hours to that first message.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given Marketplace listings and buyer messages, write SQL that returns, per category for listings created last month, the share that received a buyer message within 7 days and the median hours to that first message.

Time to first buyer interest is a key liquidity metric for Facebook Marketplace sellers. The interviewer checks first-event aggregation, excluding seller self-messages, computing medians with ordered-set aggregates, and the subtle censoring issue with listings that never get a message.

What the Interviewer Expects
  • Finds the first buyer message per listing with a LEFT JOIN
  • Excludes messages sent by the seller
  • Uses PERCENTILE_CONT for the median
  • Separates the share messaged from the conditional median
  • Discusses censoring and survival-style alternatives
Key Topics to Cover
Ordered-set aggregates
Median
First event
Censoring
Marketplace liquidity
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Why is the median among messaged listings potentially misleading?
  • How would you compute the overall median including unmessaged listings?
  • How would you compare categories with very different price ranges fairly?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Tables:

  • listings(listing_id, seller_id, category, created_at)
  • marketplace_messages(message_id, listing_id, sender_id, sent_at)

Sellers also send messages in the same thread, so the first buye...

Approach
  1. For each October listing, LEFT JOIN messages from non-sellers sent after creation; take MIN to get the first buyer message.
  2. Mark whether it came within 7 days, and compute hours to it.
  3. Per ca...

Submit Your Answer
Markdown supported