Data Manipulation (SQL/Python) Interview Questions
Practice the exact questions companies are asking right now.
Compute ads revenue by geography in SQL
You have ad delivery logs for a shop-ads system. Tables ad_impressions - impression_id STRING (PK) - ts TIMESTAMP (UTC) - user_id STRING - shop_id STR...
Compute pirated-theme usage and revenue loss
You work on a theme marketplace. Some shops install pirated themes instead of paying for official themes. Assume all timestamps are in UTC. Tables sho...
Retrieve First Active and Last Inactive Dates per User
Given a table activity that tracks user activities, write a SQL query to retrieve the first active date and last inactive date for each user. Table Sc...
Write SQL for content-view analytics
Context You work with page-view event logs and need to compute several engagement/usage summaries. Assume a single table: page_views | column | type |...
Transform DataFrame and compute diff-in-diff
You are given a pandas DataFrame df with the following columns: - unit_id (string): entity identifier (e.g., user, city, driver) - group (string): eit...
Compute reply-based user metrics in 7 days
You are analyzing discussions on a social platform. Tables all_post - post_id (BIGINT, PK) - post_author_id (BIGINT, FK → user.user_id) - post_creatio...
Write SQL for video-call recipients and FR activity
Given the schema and samples below, write ANSI‑SQL to answer both questions. Assume dates are stored in UTC. Today is 2025-09-01, so “yesterday” is 20...
Write SQL using HAVING and window functions
Context You work on fraud analytics. Assume the following schema (PostgreSQL-like types): transactions - txn_id BIGINT (PK) - merchant_id BIGINT - use...
Write SQL to compare social-only vs game-only engagement
You are given two tables capturing Oculus app usage. Define an 'active day' as a UTC date on which a user generates at least one event. Consider only ...
Compute percent of active users with 50+ calls
Problem You work on a Messenger-like app. You want to measure how many active users in Great Britain (GB) today have been heavy callers recently. Tabl...
Compute active ad revenue by creation source
You work on an ads platform and need to report active ad revenue broken down by the ad’s creation source. Tables ads - ad_id BIGINT PK - advertiser_id...
Write SQL for top categories and highly active users
You are given three tables: 1) impression Event-level table of user impressions. - impression_id BIGINT (PK) - user_id BIGINT (FK → user.user_id) - pi...
Merge overlapping intervals per group in pandas
You are given a pandas DataFrame df containing time intervals for multiple groups. Input df columns: - group_id (string/int): group identifier - start...
Calculate Response Rate and Compare User Survey Ratings
USERS user_id | signup_date 10 | 2024-03-20 11 | 2024-04-01 12 | 2024-04-05 SURVEYS survey_id | user_id | sent_at 1 | 10 ...
Analyze Spending Patterns and Restaurant Performance Using SQL/Python
orders +-------------+---------+---------------+---------------------+ | delivery_id | user_id | restaurant_id | order_date | +-------------+...
Write SQL for influence score and follower growth
You are working on a social product with these tables: Tables / Schemas users - user_id BIGINT (PK) - created_at TIMESTAMP posts - post_id BIGINT (PK)...
Write SQL for percent and window changes
Use PostgreSQL. Assume today = 2025-09-01. You must use CTEs and multiple window functions. Schema and tiny samples are below. Schema: - exposures(uni...
Compute video-call SQL metrics with edge cases
Use 'today' = 2025-09-01. Assume UTC timestamps. Write SQL to answer both parts below and call out how your queries handle edge cases (duplicates, fai...
Write SQL for late-delivery metrics by window
You are given two tables. Assume PostgreSQL. Define delivery duration as delivered_at − pickup_time (exclude rows with null pickup_time or delivered_a...
Generate Weekly Revenue and Engagement Summary with Pandas
events | user_id | event_time | event_type | platform | revenue | |---------|---------------------|------------|----------|---------| | 101 ...