PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency in SQL-based data manipulation—aggregation, JOINs, CASE expressions, window functions, ranking, and metric design for user tenure segmentation and temporal activity comparisons.

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

Design SQL Query for Shop Visibility and User Activity Metrics

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

SHOP_VISIBILITY +----------+---------+------------+------------+-------------+--------------+ | user_id | shop_id | event_date | is_visible | signup_date | action_type | +----------+---------+------------+------------+-------------+--------------+ | 101 | 12 | 2023-06-01 | TRUE | 2023-05-20 | view | | 102 | 18 | 2023-06-01 | FALSE | 2021-11-02 | view | | 103 | 44 | 2023-06-02 | TRUE | 2023-06-01 | click | | 104 | 12 | 2023-06-02 | TRUE | 2020-01-15 | purchase | | 105 | 18 | 2023-06-02 | FALSE | 2023-05-30 | view | +----------+---------+------------+------------+-------------+--------------+ ##### Scenario E-commerce ‘shop visibility’ dataset used to test SQL skills and metric design. ##### Question Write a query that for each shop returns total visible days, ordered descending (GROUP BY, HAVING, ORDER BY). Extend it to include shop category with a JOIN and apply CASE logic for visibility buckets. Using window functions, rank shops by average daily visibility within their category. Define and implement a metric—using today’s snapshot—to compare activity of new versus old users by grouping users into tenure buckets and reporting activity rates. ##### Hints Compute tenure as DATEDIFF(today, signup_date); activity = active_events / users.

Quick Answer: This question evaluates proficiency in SQL-based data manipulation—aggregation, JOINs, CASE expressions, window functions, ranking, and metric design for user tenure segmentation and temporal activity comparisons.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,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)