Data Manipulation (SQL/Python) Interview Questions
Master your tech interview with our curated database of real questions from top companies.
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...
Select Top Customers Using Transaction Data Filters
transactions +----+---------+------------+--------+ | id | user_id | order_date | amount | +----+---------+------------+--------+ | 1 | 101 | 202...
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 Conversation Engagement and Reaction Usage Effectively
messages +-----------+--------+----------+--------------+---------------------+ | messageid | sender | receiver | has_reaction | timestamp |...
Analyze Group Call Adoption Using SQL Queries
CALL_LOGS | call_id | user_id | call_start | call_end | is_group_call | participant_cnt | | 101 | 12 | 2023-08-01 10:00...
Calculate Total Revenue in USD Using SQL Query
ads_revenue +---------+------------+---------+----------+ | ad_id | country | revenue | currency | +---------+------------+---------+----------+ ...
Identify Top Three Active Users by Event Date
event_log +------------+---------+-----------+---------------------+ | event_date | user_id | event_type| event_timestamp | +------------+--------...
Monitor Friend-Request System for Quality and Abuse
Friendship +--------------+-------------+---------------------+---------------------+ | requester_id | approver_id | request_ts | approval_ts...
Identify Top-3 Users by Recent Total Spend
Users +----+-------+-------------+ | id | name | joined_date | +----+-------+-------------+ | 1 | Alice | 2023-01-02 | | 2 | Bob | 2023-02-14 |...
Compute User Group Stories and Aggregate Story Engagement
user_story_engagement +---------+----------+------------+------------+-------+-------+ | user_id | story_id | story_type | created_at | views | likes ...
Calculate Average Session Length and Compare App Performance
user_sessions +---------+------------+------------+---------------------+---------------------+ | user_id | session_id | app | session_start ...
Calculate User Registration Date and 7-Day Retention Rate
user_posts +---------+--------------+-----------+ | user_id | posting_date | num_posts | +---------+--------------+-----------+ | 1 | 2023-01-01...
Improve YoY Revenue Analysis with Complementary Metrics
ads_revenue +------------+-----------+ | date | revenue | +------------+-----------+ | 2023-01-01 | 120000 | | 2023-02-01 | 125500 | | 2...
Convert Dates to Calendar Quarter Labels in SQL/Python
Transactions +----+-----------+ | id | trans_dt | +----+-----------+ | 1 | 20230115 | | 2 | 20230402 | | 3 | 20230930 | | 4 | 20231201 | +---...
Design Schema for Accurate Subscription State Tracking
subscription_events +----------+---------------------+-----------+-----------+ | user_id | event_ts | event_type| plan_type | +----------+...
Calculate Engagement Metrics for Info-Stream Content Analysis
info_stream_views +----------+-----------+--------------+----------+------------+ | post_id | viewer_id | relationship | duration | ds | +---...
Clean and Aggregate Transactions for Finance Dashboard
transactions id | user_id | amount | timestamp | category 1 | 1001 | 19.99 | 2023-01-01 09:00:00 | grocery 2 | 1001 | 5.50 | 2023...
Understand SQL Aggregations and Joins: Key Differences Explained
Employees +----+--------+--------+---------+ | id | name | salary | dept_id | +----+--------+--------+---------+ | 1 | Alice | 70000 | 1 | ...
Identify Top Spenders and Segment Customers Using Python
orders +----------+---------+------------+----------+--------------+-------------------+ | order_id | cust_id | order_date | product | order_amount |...
Analyze User Engagement with SQL Queries
events +----------+---------+---------------------+ | event_id | user_id | event_time | +----------+---------+---------------------+ | 1 ...