0% found this document useful (0 votes)
18 views3 pages

Advanced SQL 100 Questions

The document outlines a series of advanced analytical queries aimed at extracting insights from ride and food delivery data. It includes tasks such as calculating average fares, identifying active drivers, tracking customer spending trends, and detecting fraudulent activities. The queries also cover performance metrics for drivers and restaurants, customer behavior analysis, and revenue tracking across various dimensions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Advanced SQL 100 Questions

The document outlines a series of advanced analytical queries aimed at extracting insights from ride and food delivery data. It includes tasks such as calculating average fares, identifying active drivers, tracking customer spending trends, and detecting fraudulent activities. The queries also cover performance metrics for drivers and restaurants, customer behavior analysis, and revenue tracking across various dimensions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

-- Q1: [Advanced] Find the average fare per kilometer for each city over the past 6

months.
-- Q2: [Advanced] Get the top 5 most active drivers by number of rides per month.
-- Q3: [Advanced] Find all customers who have increased their average monthly
spending for 3 consecutive months.
-- Q4: [Advanced] Show customer churn rate over the last 12 months using a rolling
window.
-- Q5: [Advanced] Identify drivers whose rating dropped more than 1 point within a
30-day period.
-- Q6: [Advanced] Rank restaurants by number of repeat orders from the same
customer.
-- Q7: [Advanced] Find the busiest time slot (hour) by ride volume for each day of
the week.
-- Q8: [Advanced] Detect fraudulent rides where a single driver had more than 10
rides in an hour.
-- Q9: [Advanced] Compare average delivery time between two restaurants per day
using CTE.
-- Q10: [Advanced] Get the distribution of ride distances and identify outliers
(e.g., z-score).
-- Q11: [Advanced] Calculate time between two consecutive rides per driver using
window functions.
-- Q12: [Advanced] Identify customers who ordered food at least 3 times and took a
ride on the same day.
-- Q13: [Advanced] Show drivers with the longest average trip duration (excluding
outliers).
-- Q14: [Advanced] Use ROLLUP to display earnings breakdown per driver per month
and total.
-- Q15: [Advanced] Show how many orders were placed within 10 minutes of previous
one (session grouping).
-- Q16: [Advanced] Find drivers who served both food and rides in the same week.
-- Q17: [Advanced] Detect duplicate payments by customer ID, amount, and timestamp
range.
-- Q18: [Advanced] Create a histogram of ratings for food vs ride services.
-- Q19: [Advanced] Determine most common combinations of food items ordered
together.
-- Q20: [Advanced] Track cumulative monthly earnings by city using CTE + window.
-- Q21: [Advanced] Get 90th percentile of trip fare for each vehicle type.
-- Q22: [Advanced] Identify days with high ride cancellation rate and bad weather
(requires external join).
-- Q23: [Advanced] Show order to delivery delay time distribution per zone.
-- Q24: [Advanced] Detect delivery agents with late deliveries >10% for 3
consecutive weeks.
-- Q25: [Advanced] Cluster customers based on total orders, average fare, and last
active date (via case).
-- Q26: [Advanced] Show ratio of cash vs digital payments by city and trend.
-- Q27: [Advanced] Build a cohort table showing retention of ride users over 6
months.
-- Q28: [Advanced] Identify drivers with increasing 5-star ratings trend using
LAG/LEAD.
-- Q29: [Advanced] Find top 10 drivers with earnings > 90th percentile.
-- Q30: [Advanced] Get average delivery time grouped by item category and delivery
zone.
-- Q31: [Advanced] Determine peak hours by plotting hourly ride distribution (CTE +
CASE).
-- Q32: [Advanced] Flag drivers who were inactive for more than 14 consecutive
days.
-- Q33: [Advanced] Track customers who switched from food to ride or vice versa.
-- Q34: [Advanced] Rank drivers per city and select those in top 3 by earnings.
-- Q35: [Advanced] Detect zones with consistently high order volumes but low
delivery success.
-- Q36: [Advanced] Count number of active customers per hour per weekday.
-- Q37: [Advanced] Get correlation between ride distance and fare (requires
analytics SQL).
-- Q38: [Advanced] Build a pivoted view of number of orders per payment method by
month.
-- Q39: [Advanced] Show average time between registration and first order.
-- Q40: [Advanced] Identify underperforming restaurants with order drop > 20% MoM.
-- Q41: [Advanced] Find drivers with more than 3 low-rated rides within 5 days.
-- Q42: [Advanced] Analyze revenue share per service (ride, food) over time.
-- Q43: [Advanced] Create a ranking of riders based on frequency and fare amount
combined.
-- Q44: [Advanced] Estimate missing delivery duration using average per restaurant.
-- Q45: [Advanced] Group customers based on last order date into Active, Dormant,
Lost.
-- Q46: [Advanced] Determine number of customers using only one service type.
-- Q47: [Advanced] Find percentage of orders placed during national holidays.
-- Q48: [Advanced] Check revenue loss due to cancelled food orders per region.
-- Q49: [Advanced] Use window function to calculate running average delivery time.
-- Q50: [Advanced] Use RECURSIVE CTE to simulate referral tree of customers.
-- Q51: [Advanced] List all ride-driver pairs that happened more than 5 times.
-- Q52: [Advanced] Use CASE WHEN to classify orders into High, Medium, Low value.
-- Q53: [Advanced] Identify top performing drivers in weekends only.
-- Q54: [Advanced] Calculate revenue per km driven per driver.
-- Q55: [Advanced] Find restaurants with increasing weekly order volume.
-- Q56: [Advanced] Detect food orders where total item price doesn’t match total
paid.
-- Q57: [Advanced] Join rides and reviews to show impact of fare on rating.
-- Q58: [Advanced] Get number of cancelled rides during peak vs off-peak.
-- Q59: [Advanced] Compare delivery durations across different zones using box plot
stats.
-- Q60: [Advanced] Use LAG to detect time gap between two orders from same
customer.
-- Q61: [Advanced] Identify rides that ended after midnight but started before.
-- Q62: [Advanced] Detect orders that were placed from one city but delivered in
another.
-- Q63: [Advanced] Compare food order volume by cuisine type over quarters.
-- Q64: [Advanced] Use UNNEST-style logic to analyze combos in food orders (many-
to-many).
-- Q65: [Advanced] Get revenue concentration ratio: top 10% customers vs rest.
-- Q66: [Advanced] Estimate most profitable time windows based on earnings per
hour.
-- Q67: [Advanced] Track delivery agent performance by weekday.
-- Q68: [Advanced] Detect inconsistency between order and delivery address.
-- Q69: [Advanced] Classify cities into high/medium/low performance zones.
-- Q70: [Advanced] Generate monthly summary dashboard using GROUP BY + ROLLUP.
-- Q71: [Advanced] Identify drivers with significant earnings drop MoM.
-- Q72: [Advanced] Filter customers with 100% digital payment behavior.
-- Q73: [Advanced] Show customer average spending across both services combined.
-- Q74: [Advanced] Use NTILE to bucket customers by spending percentiles.
-- Q75: [Advanced] Compare food vs ride service frequency per customer.
-- Q76: [Advanced] Create ride delay alert system (scheduled vs actual start time).
-- Q77: [Advanced] Show city-wise ride vs food order growth trend YoY.
-- Q78: [Advanced] Use array aggregation to list all items ordered in one order.
-- Q79: [Advanced] Generate weekday/hour grid heatmap of ride activity.
-- Q80: [Advanced] Detect possible ghost accounts (same phone/email duplicates).
-- Q81: [Advanced] Evaluate customer satisfaction across multiple services.
-- Q82: [Advanced] Track median delivery time per restaurant.
-- Q83: [Advanced] Compare refund volume across services and reasons.
-- Q84: [Advanced] Build a driver engagement score using weighted formula.
-- Q85: [Advanced] Predict late delivery risk based on past performance (logistic
SQL prep).
-- Q86: [Advanced] Calculate bounce rate: orders initiated but cancelled within 5
mins.
-- Q87: [Advanced] Summarize number of payments per payment method per quarter.
-- Q88: [Advanced] Check which customers use different addresses for delivery
often.
-- Q89: [Advanced] Group drivers by average fare and rating (segmentation).
-- Q90: [Advanced] Detect geographic clusters with high activity.
-- Q91: [Advanced] Compare food order success rate per app version (join log).
-- Q92: [Advanced] Get net promoter score-like rating distribution for drivers.
-- Q93: [Advanced] Use FULL OUTER JOIN to list all customers missing in either
service.
-- Q94: [Advanced] Track time to resolve customer issues (ticketed complaints).
-- Q95: [Advanced] Monitor trend of delivery agent onboarding vs attrition.
-- Q96: [Advanced] Measure week-over-week revenue growth for food service.
-- Q97: [Advanced] Compare re-order rate of food customers across cities.
-- Q98: [Advanced] Count how many customers placed orders using promotions only.
-- Q99: [Advanced] Find percentage of food orders delivered under 30 minutes.
-- Q100: [Advanced] Identify zones with highest refund volume.
-- Q101: [Advanced] Track usage of coupons per customer and total discount availed.
-- Q102: [Advanced] Compare average customer lifetime value by city.
-- Q103: [Advanced] Summarize number of active users per device type (if tracked).
-- Q104: [Advanced] Track bounce-back of churned customers within 90 days.
-- Q105: [Advanced] Classify customer behavior trend as Loyal, Occasional, Churned.
-- Q106: [Advanced] Create leaderboard of drivers by positive review rate.

You might also like