SQL GROUP BY and Aggregation Interview Questions
Most analytics questions boil down to grouping rows and summarising them. Practise COUNT, SUM and AVG, filtering groups with HAVING, counting distinct values and building ratios with conditional aggregation.
20 questions · 8 Easy · 8 Medium · 4 Hard · about 3 hours · MySQL & PostgreSQL
What you'll practise
- GROUP BY on one or more columns
- HAVING vs WHERE
- COUNT DISTINCT
- Conditional aggregation with CASE
- Percentages and ratios
- Pivoting rows into columns
Learn the concepts first
Questions in this plan
Multilingual Language Speakers
Identify users who speak at least two distinct target languages ('English', 'Spanish', 'German') from skill profile records.
Daily Active Users (DAU)
Compute the daily count of unique active users from raw product activity event timestamps.
Ad Click-Through Rate (CTR)
Calculate the percentage CTR per ad campaign rounded to 2 decimals, safely handling campaigns with zero impressions.
Play Store: Top Rated App Categories
Find categories with at least 3 apps rated 4.0 or higher, returning the category, app count, and average rating rounded to 2 decimals.
Google Maps: High-Impact Local Guides
Find verified reviewers who submitted at least 2 photo reviews in San Francisco or Mountain View.
Google Drive: External Sensitive File Shares
Audit sensitive files shared with non-Google email addresses to identify potential data exposure risks.
Find Duplicate Emails
Report all duplicate emails present in the Person table using aggregate grouping.
Cities With Most Loyal Customers
Group users by metropolitan territory and rank locations by repeat checkout count over 90 days.
Google Workspace: Storage Quota Alerts
Calculate total Drive storage per organization and return those exceeding their quota, showing total used and excess GB.
YouTube: Breakout Videos Dominating Channels
Find videos that account for at least 50% of their channel total views, calculating each video view percentage.
Google Play: High-Value Repeat Spenders
Identify key monetization users in target regions who executed 3+ in-app purchases totaling over $100.
Month-over-Month Revenue Growth
Compute monthly successful payment volume and its percentage change versus the prior month.
Restaurants With Most Orders
Aggregate total order volume per merchant and return the top 5 partner restaurants.
Amazon: Repeat Purchase Rate
Calculate the percentage of all registered customers who have placed two or more orders, rounded to 2 decimal places.
Amazon: Monthly Category Revenue Pivot
Pivot monthly product category sales into dedicated columns for Electronics, Apparel, and Home merchandise.
Amazon: Marketplace Seller Return Rate
Identify marketplace merchants with at least 5 fulfilled orders whose customer return rate exceeds 10%.
Trips and Users Cancellation Rate
Calculate unbanned driver and client cancellation rate during peak holiday weekend dates.
Amazon: Frequently Bought Together
Identify product pairs purchased together in the same order at least 3 times without duplicate pairs or reflexive matches.
Amazon: Prime Monthly Churn Rate
Calculate monthly Prime subscriber churn rates using calendar intervals and conditional status aggregations.
Monthly Net Revenue by Customer
Net payments, refunds and chargebacks into the month each money movement happened.