Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Top 10% Pinners by Promoted Engagement
00:00
5 left

Top 10% Pinners by Promoted Engagement

MediumSQL · PostgreSQL

Problem

How would you write a SQL query to identify the top 10% of Pinners based on their engagement with promoted pins on Pinterest?

Use all Pinners, including those with no qualifying engagement. Rank by total engagement descending, break ties by pinner_id ascending, and use the ceiling of 10% when the population size does not divide evenly.

Output

  1. One row per selected Pinner with pinner_id, username, total_engagements, and engagement_rank
  2. Include only the top 10%, ordered by engagement_rank ascending, then pinner_id ascending

Schema

pinners
ColumnTypeDescription
pinner_idPKINTUnique identifier for a Pinner
usernameVARCHAR(100)Pinterest username
promoted_pins
ColumnTypeDescription
promoted_pin_idPKINTUnique identifier for a promoted Pin
pinner_idINTPinner who owns or published the promoted Pin
pin_titleVARCHAR(150)Short title of the promoted Pin
statusVARCHAR(20)Promotion status
promoted_pin_engagements
ColumnTypeDescription
engagement_idPKINTUnique identifier for an engagement event
promoted_pin_idINTPromoted Pin associated with the engagement
pinner_idINTPinner who generated the engagement
engagement_typeVARCHAR(30)Type of engagement event
Tablespinnerspromoted_pinspromoted_pin_engagements
Interviewer

Your question is Top 10% Pinners by Promoted Engagement. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.