PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates proficiency with SQL data manipulation, window functions for rolling aggregates, deduplication of user events, and text-filtering of metadata.

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

Compute 7-Day Rolling Average of Unique Post Viewers

Company: TikTok

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

POST_VIEWS +---------+------------+---------+ | user_id | view_date | post_id | | 101 | 2023-08-01 | 10 | | 102 | 2023-08-01 | 11 | | 101 | 2023-08-02 | 10 | | 103 | 2023-08-03 | 12 | | 104 | 2023-08-03 | 10 | ​ POSTS +---------+----------------------+-------------------------+ | post_id | content | hashtags | | 10 | 'Apple launch video' | '#Apple #iPhone #Launch'| | 11 | 'Recipe tutorial' | '#Food #Recipe' | | 12 | 'Travel vlog' | '#Travel #Adventure' | | 13 | 'Tech news' | '#Tech #Apple' | | 14 | 'Fitness tips' | '#Health' | ##### Scenario A social-media analytics team has two tables: POST_VIEWS records every user’s daily post views, and POSTS stores post metadata including a free-text hashtags field. ##### Question Write an SQL query to compute, for every post, the 7-day rolling average of daily unique viewers ordered by view_date. Given a search term (e.g. 'Apple'), return all post_id values whose hashtags column contains that term (case-insensitive). State the logical execution order of SQL clauses (e.g. FROM, WHERE, GROUP BY…) and explain why knowing this order matters when debugging or optimizing queries. ##### Hints Use COUNT(DISTINCT user_id) over a 7-day RANGE window; apply ILIKE or LOWER(hashtags) LIKE '%apple%'.

Quick Answer: This question evaluates proficiency with SQL data manipulation, window functions for rolling aggregates, deduplication of user events, and text-filtering of metadata.

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

  • Find high-value crypto users and top-CTR product - TikTok (easy)
  • Write monthly customer and sales SQL queries - TikTok (easy)
  • Find top-paid employee per department - TikTok (easy)
  • Count buggy vs non-buggy by employer - TikTok (Medium)
  • Select max-discount product per category - TikTok (Medium)