PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's competency in SQL data manipulation, specifically aggregating event data and applying time-window filters to produce ranked metrics.

  • Medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Scientist

Retrieve Top Five Ads by Conversions in 30 Days

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

ads ad_id | advertiser_id | created_at 1 | 101 | 2024-06-01 2 | 102 | 2024-06-03 3 | 101 | 2024-06-10 ​ ad_impressions impression_id | ad_id | user_id | impression_date 1001 | 1 | 501 | 2024-06-15 1002 | 2 | 502 | 2024-06-15 1003 | 1 | 503 | 2024-06-16 1004 | 3 | 501 | 2024-06-17 1005 | 2 | 504 | 2024-06-18 ​ ad_conversions conversion_id | impression_id | revenue | conversion_date 2001 | 1001 | 5.00 | 2024-06-15 2002 | 1003 | 2.50 | 2024-06-16 2003 | 1005 | 7.00 | 2024-06-18 ##### Scenario Analyze advertising performance; return the top N ads by conversions in the last M days using three related tables. ##### Question Write SQL to return the five ads with the highest number of conversions in the past 30 days. Output ad_id, advertiser_id, total_conversions, sorted by total_conversions DESC. Exclude ads with zero conversions and handle impressions that never converted. ##### Hints LEFT JOIN impressions to conversions, filter on date range, GROUP BY ad_id.

Quick Answer: This question evaluates a candidate's competency in SQL data manipulation, specifically aggregating event data and applying time-window filters to produce ranked metrics.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
  • Write SQL for call metrics - Meta (medium)
  • Write SQL for multi-account metrics - Meta (medium)