PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates the ability to perform time-windowed aggregations, cumulative transaction summation, cross-table joins, and click-through-rate (CTR) calculations using SQL or Python, with attention to timestamp handling and event filtering.

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

Find high-value crypto users and top-CTR product

Company: TikTok

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Technical Screen

You are given three tables (timezone: UTC). Assume `create_date`, `transaction_time`, and `event_time` are timestamps. ## Tables ### `users` - `user_id` BIGINT PRIMARY KEY - `create_date` TIMESTAMP -- account creation time ### `transactions` - `transaction_id` BIGINT PRIMARY KEY - `user_id` BIGINT NOT NULL REFERENCES `users(user_id)` - `transaction_time` TIMESTAMP NOT NULL - `product` VARCHAR NOT NULL -- e.g., `'crypto'`, `'card'`, etc. - `amount_gbp` NUMERIC(18,2) NOT NULL - `status` VARCHAR NOT NULL -- `'completed'` or `'declined'` ### `activity` - `user_id` BIGINT NOT NULL REFERENCES `users(user_id)` - `event_time` TIMESTAMP NOT NULL - `product` VARCHAR NOT NULL - `event_type` VARCHAR NOT NULL -- `'view'` or `'click'` ## Tasks ### 1) Find users with > £100 completed crypto volume in first 7 days Return all users whose **cumulative** `amount_gbp` from **completed** transactions with `product = 'crypto'` is **strictly greater than 100** within the window: - from `users.create_date` (inclusive) - to `users.create_date + INTERVAL '7 days'` (exclusive) **Output columns**: - `user_id` - `crypto_amount_7d_gbp` ### 2) Find the product with the highest CTR Using the `activity` table, compute per-product: - `views = count(*) where event_type = 'view'` - `clicks = count(*) where event_type = 'click'` - `ctr = clicks / views` Return the product with the **highest CTR**. **Output columns**: - `product` - `ctr` Notes: - Define how you handle products with `views = 0` (e.g., exclude them).

Quick Answer: This question evaluates the ability to perform time-windowed aggregations, cumulative transaction summation, cross-table joins, and click-through-rate (CTR) calculations using SQL or Python, with attention to timestamp handling and event filtering.

Last updated: May 7, 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

  • 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)
  • Write SQL for 7-day geo-localized revenue dashboard - TikTok (Medium)