Top Three Boards per Creator by Saves in a Calendar Week

Last updated: November 29, 2026

Quick Overview

Given boards(board_id, owner_id) and saves(save_id, board_id, saved_at), return each creator's top three boards by number of saves during the week of 2026-11-02, with a deterministic tie-break.

Pinterest
Data Manipulation (SQL/Python)
Data Scientist
Pinterest
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Given boards(board_id, owner_id) and saves(save_id, board_id, saved_at), return each creator's top three boards by number of saves during the week of 2026-11-02, with a deterministic tie-break.

Creator analytics at Pinterest summarizes which boards are driving engagement, and this kind of ranking query is a standard SQL screen for data scientists. The interviewer checks window function fluency, a correct half-open date filter, and an explicit choice between ROW_NUMBER, RANK and DENSE_RANK.

What the Interviewer Expects
  • Filters the week with a half-open date range
  • Aggregates before ranking
  • Uses ROW_NUMBER partitioned by owner with a tie-break column
  • Explains when RANK or DENSE_RANK would be preferable
  • Notes that boards with zero saves are excluded and asks if that is intended
Key Topics to Cover
window functions
ROW_NUMBER
aggregation
date filtering
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
  • How would you include boards with zero saves?
  • How would you compute the rank change versus the previous week?
  • How would you make this efficient on a table with billions of saves?
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
  • saves has one row per save event; saved_at is a date or timestamp.
  • A board belongs to exactly one owner (group boards would need a collaborators table, worth asking).
  • 'Week of 2026-11-02' means ...
Approach

Aggregate saves per (owner, board) inside the week, then rank within owner using ROW_NUMBER ordered by saves descending and board_id ascending, and keep rn <= 3. Ranking must happen after aggregation,...


Submit Your Answer
Markdown supported