SQL Practice Challenges – Solve Real Interview Questions

Practice SQL queries with 389 hand-crafted challenges that mirror real interview questions. Improve your skills across SELECT, JOINs, GROUP BY, CTEs, and window functions β€” all in a live SQL editor with instant feedback. First 30 are free β€” upgrade for full access.

1
Select All Users
Retrieve all columns from the users table, limited to 20 rows.
SELECTLIMIT
Easy
β†’
2
Active Products
Find all active products, showing name, category, price and rating. Order by rating descending.
SELECTWHEREORDER BY
Easy
β†’
3
Orders by Status
Count how many orders exist for each status.
GROUP BYCOUNT
Easy
β†’
4
Premium Users
List all premium users (is_premium = 1) showing their full name, email and city.
SELECTWHERECONCAT
Easy
β†’
5
Select All Users (No Limit)
Retrieve all columns from the users table without any row limit.
SELECT
Easy
β†’
6
User Names Only
Get first_name and last_name of all users.
SELECT
Easy
β†’
7
Unique Cities
Find distinct cities from users.
DISTINCT
Easy
β†’
8
Total Users
Count total number of users.
COUNT
Easy
β†’
9
Premium Users
Get all users who are premium.
WHERE
Easy
β†’
10
Users from India
Retrieve users located in India.
WHERE
Easy
β†’
11
Highest Salary First
List employees sorted by salary descending.
ORDER BY
Easy
β†’
12
Top 5 Expensive Products
Find 5 most expensive products.
ORDER BYLIMIT
Easy
β†’
13
Cheapest Product
Find minimum product price.
MIN
Easy
β†’
14
Most Expensive Product
Find maximum product price.
MAX
Easy
β†’
15
Average Product Price
Find average price of products.
AVG
Easy
β†’
16
Total Order Amount
Calculate total order value.
SUM
Easy
β†’
17
Orders by Status
Count orders grouped by status.
GROUP BYCOUNT
Easy
β†’
18
Products per Category
Count products in each category.
GROUP BY
Easy
β†’
19
Recent Users
Find users created after 2023-01-01.
WHERE
Easy
β†’
20
Employees in IT
Find employees in IT department.
WHERE
Easy
β†’
21
High Salary Employees
Find employees with salary greater than 50000.
WHERE
Easy
β†’
22
Discounted Orders
Get all orders where discount is greater than 0.
WHERE
Easy
β†’
23
Available Products
Find products with stock greater than 0.
WHERE
Easy
β†’
24
Users Without Phone
Find users who have no phone number.
WHERE
Easy
β†’
25
Top Rated Products
List products sorted by rating descending.
ORDER BY
Easy
β†’
26
Lowest Salary
Find the employee with the lowest salary.
ORDER BYLIMIT
Easy
β†’
27
Top 3 Salaries
Find top 3 highest paid employees.
ORDER BYLIMIT
Easy
β†’
28
Total Products
Count total number of products.
COUNT
Easy
β†’
29
Average Salary
Calculate average salary of employees.
AVG
Easy
β†’
30
Total Discounts
Find total discount given on orders.
SUM
Easy
β†’
πŸ”’
Highest Review Rating
Find the highest rating given in reviews.
MAX
Easy
πŸ”’
πŸ”’
Lowest Review Rating
Find the lowest rating given in reviews.
MIN
Easy
πŸ”’
πŸ”’
Orders by Country
Count orders grouped by shipping_country.
GROUP BY
Easy
πŸ”’
πŸ”’
Users per City
Count users in each city.
GROUP BY
Easy
πŸ”’
πŸ”’
Products by Status
Count products grouped by status.
GROUP BY
Easy
πŸ”’
πŸ”’
Employees per Department
Count employees in each department.
GROUP BY
Easy
πŸ”’
πŸ”’
Large Orders
Find orders with item_count greater than 5.
WHERE
Easy
πŸ”’
πŸ”’
Active Users
Retrieve users with status active.
WHERE
Easy
πŸ”’
πŸ”’
Recent Employees
Find employees hired after 2020.
WHERE
Easy
πŸ”’
πŸ”’
Most Helpful Reviews
Find top 5 reviews by helpful_votes.
ORDER BYLIMIT
Easy
πŸ”’
πŸ”’
Gmail Users
Find users whose email contains gmail.
WHERE
Easy
πŸ”’
πŸ”’
Products in Price Range
Find products priced between 100 and 500.
WHERE
Easy
πŸ”’
πŸ”’
Names Starting with A
Find employees whose first name starts with A.
WHERE
Easy
πŸ”’
πŸ”’
Pending Orders
Find all orders with status pending.
WHERE
Easy
πŸ”’
πŸ”’
Low Stock Products
Find products with stock less than 10.
WHERE
Easy
πŸ”’
πŸ”’
Premium User Count
Count number of premium users.
COUNT
Easy
πŸ”’
πŸ”’
Big Orders
Find orders where total is greater than 1000.
WHERE
Easy
πŸ”’
πŸ”’
Employees in Delhi
Find employees based in Delhi.
WHERE
Easy
πŸ”’
πŸ”’
Products Price Ascending
Sort products by price ascending.
ORDER BY
Easy
πŸ”’
πŸ”’
First 10 Users
Retrieve first 10 users.
LIMIT
Easy
πŸ”’
πŸ”’
Latest Orders
Get 5 most recent orders.
ORDER BYLIMIT
Easy
πŸ”’
πŸ”’
Total Stock
Find total stock of all products.
SUM
Easy
πŸ”’
πŸ”’
Average Helpful Votes
Find average helpful votes in reviews.
AVG
Easy
πŸ”’
πŸ”’
Unique Categories
Get distinct product categories.
DISTINCT
Easy
πŸ”’
πŸ”’
Total Orders
Count total orders.
COUNT
Easy
πŸ”’
πŸ”’
Highest Order Value
Find maximum order total.
MAX
Easy
πŸ”’
πŸ”’
Lowest Order Value
Find minimum order total.
MIN
Easy
πŸ”’
πŸ”’
Users from USA
Find users located in USA.
WHERE
Easy
πŸ”’
πŸ”’
Active Employees
Find employees with active status.
WHERE
Easy
πŸ”’
πŸ”’
Popular Products
Find products with review_count greater than 100.
WHERE
Easy
πŸ”’
πŸ”’
Old Users
Find users created before 2022.
WHERE
Easy
πŸ”’
πŸ”’
Shipped Orders
Find orders that have been shipped.
WHERE
Easy
πŸ”’
πŸ”’
Unshipped Orders
Find orders that are not shipped yet.
WHERE
Easy
πŸ”’
πŸ”’
Active Products
Retrieve products with active status.
WHERE
Easy
πŸ”’
πŸ”’
Mid Salary Employees
Find employees with salary between 30000 and 70000.
WHERE
Easy
πŸ”’
πŸ”’
Products Containing Phone
Find products whose name contains "phone".
WHERE
Easy
πŸ”’
πŸ”’
Names Containing Ra
Find users whose first name contains "ra".
WHERE
Easy
πŸ”’
πŸ”’
Employees by Hire Date
Sort employees by hire_date ascending.
ORDER BY
Easy
πŸ”’
πŸ”’
Orders by Amount
Sort orders by total ascending.
ORDER BY
Easy
πŸ”’
πŸ”’
Top Rated Products Limit
Find top 10 highest rated products.
ORDER BYLIMIT
Easy
πŸ”’
πŸ”’
Users per Country
Count users grouped by country.
GROUP BY
Easy
πŸ”’
πŸ”’
Avg Price per Category
Find average product price per category.
GROUP BYAVG
Easy
πŸ”’
πŸ”’
Total Sales by Status
Sum order totals grouped by status.
GROUP BYSUM
Easy
πŸ”’
πŸ”’
Max Salary per Department
Find highest salary in each department.
GROUP BYMAX
Easy
πŸ”’
πŸ”’
Min Price per Category
Find minimum product price per category.
GROUP BYMIN
Easy
πŸ”’
πŸ”’
Reviews per Product
Count number of reviews for each product.
GROUP BY
Easy
πŸ”’
πŸ”’
Orders by Item Count Range
Find orders with item_count between 2 and 10.
WHERE
Easy
πŸ”’
πŸ”’
Employees Not in Mumbai
Find employees not located in Mumbai.
WHERE
Easy
πŸ”’
πŸ”’
Products Price >= 1000
Find products with price greater or equal to 1000.
WHERE
Easy
πŸ”’
πŸ”’
Newest Users First
Sort users by created_at descending.
ORDER BY
Easy
πŸ”’
πŸ”’
Total Employees
Count total number of employees.
COUNT
Easy
πŸ”’
πŸ”’
Total Salary Expense
Calculate total salary paid to all employees.
SUM
Easy
πŸ”’
πŸ”’
Average Order Value
Find average total of all orders.
AVG
Easy
πŸ”’
πŸ”’
Unique User Countries
List distinct countries of users.
DISTINCT
Easy
πŸ”’
πŸ”’
Orders by Oldest First
Sort orders by order_date ascending.
ORDER BY
Easy
πŸ”’
πŸ”’
Profitable Products
Find products where cost is less than price.
WHERE
Easy
πŸ”’
πŸ”’
Users With Phone
Find users who have a phone number.
WHERE
Easy
πŸ”’
πŸ”’
Managers
Find employees with title Manager.
WHERE
Easy
πŸ”’
πŸ”’
Out of Stock Products
Find products with zero stock.
WHERE
Easy
πŸ”’
πŸ”’
No Discount Orders
Find orders with no discount.
WHERE
Easy
πŸ”’
πŸ”’
Highest Paid Employee
Find the employee with the highest salary.
ORDER BYLIMIT
Easy
πŸ”’
πŸ”’
Cheapest Product Record
Find product with lowest price.
ORDER BYLIMIT
Easy
πŸ”’
πŸ”’
Latest Reviews
Sort reviews by reviewed_at descending.
ORDER BY
Easy
πŸ”’
πŸ”’
Successful Payments
Find payments with status success.
WHERE
Easy
πŸ”’
πŸ”’
Card Payments
Find payments made using card method.
WHERE
Easy
πŸ”’
πŸ”’
Total Payments
Count total number of payments.
COUNT
Easy
πŸ”’
πŸ”’
Total Payment Amount
Calculate total amount of all payments.
SUM
Easy
πŸ”’
πŸ”’
Average Payment
Find average payment amount.
AVG
Easy
πŸ”’
πŸ”’
Max Payment
Find highest payment amount.
MAX
Easy
πŸ”’
πŸ”’
Min Payment
Find lowest payment amount.
MIN
Easy
πŸ”’
πŸ”’
Payments by Status
Count payments grouped by status.
GROUP BY
Easy
πŸ”’
πŸ”’
Payments by Method
Count payments grouped by method.
GROUP BY
Easy
πŸ”’
πŸ”’
Average Salary per Department
Find average salary grouped by department.
GROUP BYAVG
Easy
πŸ”’
πŸ”’
Total Stock per Category
Find total stock grouped by product category.
GROUP BYSUM
Easy
πŸ”’
πŸ”’
Top Customers by Revenue
Find the top 15 customers by total lifetime order value. Show their full name, email, number of orders, and total spent.
JOINGROUP BYSUM
Medium
πŸ”’
πŸ”’
Revenue by Product Category
Calculate total revenue, units sold and number of orders per product category.
JOINGROUP BYSUM
Medium
πŸ”’
πŸ”’
Monthly Revenue Trend
Show monthly order revenue for the last 12 months, excluding cancelled orders.
DATEGROUP BYSUBSTR
Medium
πŸ”’
πŸ”’
Payment Method Analysis
Analyze payment methods: show transaction count, success rate (%), total revenue per method.
CASE WHENGROUP BYConditional Aggregation
Medium
πŸ”’
πŸ”’
Department Salary Statistics
For each department, show headcount, average salary, min and max salary.
GROUP BYAVGMIN
Medium
πŸ”’
πŸ”’
Orders with Product Info
Get order_items along with product name.
JOIN
Medium
πŸ”’
πŸ”’
Top Selling Products
Find products with highest total quantity sold.
GROUP BYORDER BY
Medium
πŸ”’
πŸ”’
Orders in Last 30 Days
Find orders placed in last 30 days.
DATE
Medium
πŸ”’
πŸ”’
Users with Multiple Orders
Find users who placed more than 3 orders.
HAVING
Medium
πŸ”’
πŸ”’
Average Order Value per User
Find average order value for each user.
AVG
Medium
πŸ”’
πŸ”’
Orders with Payment Status
Join orders with payments to get payment status.
JOIN
Medium
πŸ”’
πŸ”’
Users with Highest Order
Find users who placed the highest order.
SUBQUERY
Medium
πŸ”’
πŸ”’
Second Highest Order
Find second highest order total.
ORDER BY
Medium
πŸ”’
πŸ”’
Employees Above Dept Avg
Find employees earning more than department average.
SUBQUERY
Medium
πŸ”’
πŸ”’
Products Never Ordered
Find products not present in order_items.
JOIN
Medium
πŸ”’
πŸ”’
Order Item Counts
Find total items per order.
GROUP BY
Medium
πŸ”’
πŸ”’
Last Order Date per User
Find last order date for each user.
GROUP BY
Medium
πŸ”’
πŸ”’
Revenue per Day
Calculate total revenue per day.
GROUP BY
Medium
πŸ”’
πŸ”’
Orders with Many Products
Find orders having more than 3 items.
HAVING
Medium
πŸ”’
πŸ”’
Employees with Manager Names
Show employees with their manager name.
JOIN
Medium
πŸ”’
πŸ”’
Orders by Shipping City
Count orders grouped by shipping city.
GROUP BY
Medium
πŸ”’
πŸ”’
Users Active in 2024
Find users who placed orders in 2024.
DATE
Medium
πŸ”’
πŸ”’
Department Highest Salary
Find highest salary employee in each department.
SUBQUERY
Medium
πŸ”’
πŸ”’
Orders with User City
Get orders along with user city.
JOIN
Medium
πŸ”’
πŸ”’
Highly Rated Products
Find products with average rating above 4.
HAVING
Medium
πŸ”’
πŸ”’
Revenue per Product
Calculate total revenue generated by each product.
GROUP BYSUM
Medium
πŸ”’
πŸ”’
Top 5 Users by Spend
Find top 5 users based on total spending.
GROUP BYORDER BY
Medium
πŸ”’
πŸ”’
Orders Above Average
Find orders with total greater than average order total.
SUBQUERY
Medium
πŸ”’
πŸ”’
Users with Most Reviews
Find users who have written the most reviews.
GROUP BYORDER BY
Medium
πŸ”’
πŸ”’
Average Rating per Category
Find average product rating by category.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Order Summary
Get total quantity and total amount per order.
GROUP BY
Medium
πŸ”’
πŸ”’
Users with Big Orders
Find users who placed at least one order above 1000.
WHERE
Medium
πŸ”’
πŸ”’
Orders per Month
Count orders per month.
DATEGROUP BY
Medium
πŸ”’
πŸ”’
Last Order Amount per User
Find last order total for each user.
SUBQUERY
Medium
πŸ”’
πŸ”’
Employees Hired per Year
Count employees hired each year.
DATEGROUP BY
Medium
πŸ”’
πŸ”’
Orders by Payment Method
Join orders with payments to get method.
JOIN
Medium
πŸ”’
πŸ”’
Product Sales Volume
Find total quantity sold per product.
GROUP BY
Medium
πŸ”’
πŸ”’
High Discount Orders
Find orders where discount is above average.
SUBQUERY
Medium
πŸ”’
πŸ”’
Top Users by Orders
Find users who placed the most orders.
GROUP BYORDER BY
Medium
πŸ”’
πŸ”’
Least Selling Products
Find products with lowest sales quantity.
GROUP BYORDER BY
Medium
πŸ”’
πŸ”’
Daily Orders per User
Count orders per user per day.
GROUP BY
Medium
πŸ”’
πŸ”’
Employees in Same Department
Find pairs of employees in same department.
JOIN
Medium
πŸ”’
πŸ”’
Orders with High Item Count
Find orders with item count above average.
SUBQUERY
Medium
πŸ”’
πŸ”’
Users Without Reviews
Find users who never wrote a review.
JOIN
Medium
πŸ”’
πŸ”’
Product Review Count
Count number of reviews per product.
GROUP BY
Medium
πŸ”’
πŸ”’
Users Orders & Spend
Find total orders and total spend per user.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Products Above Avg Price
Find products priced above average.
SUBQUERY
Medium
πŸ”’
πŸ”’
Orders with User Country
Show orders along with user country.
JOIN
Medium
πŸ”’
πŸ”’
Monthly Revenue (strftime)
Calculate total revenue per month using strftime to extract year-month.
DATEGROUP BY
Medium
πŸ”’
πŸ”’
Below Avg Salary Employees
Find employees earning below average salary.
SUBQUERY
Medium
πŸ”’
πŸ”’
Orders with Highest Discount
Find orders with maximum discount.
SUBQUERY
Medium
πŸ”’
πŸ”’
User Orders & Avg Spend
Find total orders and average order value per user.
GROUP BY
Medium
πŸ”’
πŸ”’
Revenue per Product
Find total revenue per product.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Orders with User & Payment
Get order id, user name and payment status.
JOIN
Medium
πŸ”’
πŸ”’
Employees per City
Count employees grouped by city.
GROUP BY
Medium
πŸ”’
πŸ”’
Orders per User Last Year
Count orders per user in last year.
DATEGROUP BY
Medium
πŸ”’
πŸ”’
Above Avg Rated Products
Find products with average rating above overall average.
HAVINGSUBQUERY
Medium
πŸ”’
πŸ”’
Max Order per User
Find maximum order amount for each user.
GROUP BY
Medium
πŸ”’
πŸ”’
Order Item Avg Price
Find average unit price per order.
GROUP BY
Medium
πŸ”’
πŸ”’
Salary Above Dept Max
Find employees whose salary is equal to max in their department.
SUBQUERY
Medium
πŸ”’
πŸ”’
Users Above Avg Orders Count
Find users whose order count is above average.
HAVINGSUBQUERY
Medium
πŸ”’
πŸ”’
Product Count per Order
Find distinct products count per order.
GROUP BY
Medium
πŸ”’
πŸ”’
Products Without Reviews
Find products that have no reviews.
JOIN
Medium
πŸ”’
πŸ”’
Employees with Same Salary
Find employees who share same salary.
GROUP BYHAVING
Medium
πŸ”’
πŸ”’
Orders with User & Items
Find order id, user id and total items.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Users Orders & Payments Count
Find total orders and payments per user.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Orders with Full User Info
Retrieve orders with all user details.
JOIN
Medium
πŸ”’
πŸ”’
Most Reviewed Products
Find products with highest number of reviews.
GROUP BYORDER BY
Medium
πŸ”’
πŸ”’
Lowest Salary per Department
Find employees with lowest salary in each department.
SUBQUERY
Medium
πŸ”’
πŸ”’
Order Quantity & Avg Price
Find total quantity and avg unit price per order.
GROUP BY
Medium
πŸ”’
πŸ”’
Users Ordering Across Countries
Find users who placed orders in more than one shipping country.
GROUP BYHAVING
Medium
πŸ”’
πŸ”’
Products Above Avg Revenue
Find products generating revenue above average.
HAVINGSUBQUERY
Medium
πŸ”’
πŸ”’
Employees Sharing Same Manager
Find employees who share the same manager.
GROUP BYHAVING
Medium
πŸ”’
πŸ”’
Shipping Delay
Find orders where shipping took more than 3 days.
DATE
Medium
πŸ”’
πŸ”’
Users with Highest Single Order
Find users who made the highest value single order.
SUBQUERY
Medium
πŸ”’
πŸ”’
Orders with Multiple Products
Find orders containing more than one distinct product.
GROUP BYHAVING
Medium
πŸ”’
πŸ”’
Employees Salary Ranking Style
Sort employees by salary descending with department.
ORDER BY
Medium
πŸ”’
πŸ”’
Order vs Payment Amount
Find orders where payment amount differs from order total.
JOIN
Medium
πŸ”’
πŸ”’
Top Users per City
Find users with highest number of orders in each city.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Product Reviews & Sales
Find products with both review count and total sales.
JOINGROUP BY
Medium
πŸ”’
πŸ”’
Employees Above Company Avg
Find employees earning above company average.
SUBQUERY
Medium
πŸ”’
πŸ”’
Orders per Country with Avg
Find total orders and avg order value per country.
GROUP BY
Medium
πŸ”’
πŸ”’
Users Above Avg Reviews
Find users whose review count is above average.
HAVINGSUBQUERY
Medium
πŸ”’
πŸ”’
Highest Items per Day
Find order with highest item_count each day.
SUBQUERY
Medium
πŸ”’
πŸ”’
Price Above Category Avg
Find products priced above their category average.
SUBQUERY
Medium
πŸ”’
πŸ”’
Second Highest Salary
Find employees with the second highest salary. Handle ties correctly.
SubqueryDISTINCTOFFSET
Hard
πŸ”’
πŸ”’
Running Revenue Total
Show monthly revenue with a running cumulative total using a subquery.
CTEWITHCorrelated Subquery
Hard
πŸ”’
πŸ”’
Customer RFM Segmentation
Segment customers by Recency (last order), Frequency (order count) and Monetary value. Label them as VIP, Regular, or At-Risk.
CTECASE WHENSegmentation
Hard
πŸ”’
πŸ”’
Product Performance Dashboard
For each product: units sold, revenue, average review rating, profit margin %. Use JOINs across 3 tables.
Multi-JOINCOALESCELEFT JOIN
Hard
πŸ”’
πŸ”’
Find Duplicate Emails
Find duplicate emails in users table.
GROUP BYHAVINGDATA CLEANING
Hard
πŸ”’
πŸ”’
Identify Duplicate Users
Find users with duplicate emails. For each duplicate group, show the email, how many times it appears, and the IDs of all duplicate rows ordered by creation date (newest first). Only show rows that would be removed if deduplication were applied β€” i.e. every row except the most-recent per email.
WINDOW FUNCTIONDATA CLEANINGROW_NUMBER
Hard
πŸ”’
πŸ”’
Consecutive Order Days
Find users who placed orders on 3 consecutive days.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
Running Total Revenue
Calculate running total of revenue by date.
WINDOW FUNCTIONRUNNING TOTALAGGREGATION
Hard
πŸ”’
πŸ”’
Rank Products by Category
Rank products by price within each category.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Top 3 Products per Category
Find top 3 expensive products in each category.
WINDOW FUNCTIONPARTITIONFILTER
Hard
πŸ”’
πŸ”’
Customers Who Never Ordered
Find users who never placed an order.
JOINFILTERANTI JOIN
Hard
πŸ”’
πŸ”’
Highest Spend Order per User
Find highest order value for each user.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Dense Rank Orders
Assign dense rank to orders based on total.
WINDOW FUNCTIONRANKINGORDER
Hard
πŸ”’
πŸ”’
Pivot Order Status
Count orders by status in columns.
CASEPIVOTAGGREGATION
Hard
πŸ”’
πŸ”’
Moving Average Orders
Calculate 3-day moving average of order totals.
WINDOW FUNCTIONMOVING AVERAGEANALYTICS
Hard
πŸ”’
πŸ”’
Gap Between Orders
Find days between consecutive orders per user.
WINDOW FUNCTIONLAGDATE
Hard
πŸ”’
πŸ”’
Top Spender per Country
Find highest spending user in each country.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Order Percentage Contribution
Find each order’s contribution percentage to total revenue.
WINDOW FUNCTIONPERCENTAGEAGGREGATION
Hard
πŸ”’
πŸ”’
First Order per User
Find first order for each user.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Last Order per User
Find most recent order for each user.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Top 2 Salaries per Department
Find top 2 highest salaries in each department.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Duplicate Orders Detection
Find duplicate orders based on same user_id and total.
GROUP BYHAVINGDATA CLEANING
Hard
πŸ”’
πŸ”’
Employee Hierarchy Level
Find level of each employee in hierarchy.
CTERECURSIONHIERARCHY
Hard
πŸ”’
πŸ”’
Cumulative Spend per User
Calculate cumulative spend per user ordered by date.
WINDOW FUNCTIONRUNNING TOTALPARTITION
Hard
πŸ”’
πŸ”’
Orders in 7 Day Window
Find total orders within 7-day rolling window.
WINDOW FUNCTIONROLLING WINDOWANALYTICS
Hard
πŸ”’
πŸ”’
Global Product Sales Rank
Rank products by total sales globally.
WINDOW FUNCTIONGROUP BYRANKING
Hard
πŸ”’
πŸ”’
Hiring Gaps
Find gap in days between hires.
WINDOW FUNCTIONLAGDATE
Hard
πŸ”’
πŸ”’
Revenue Share by Category
Find percentage revenue per category.
WINDOW FUNCTIONPERCENTAGEGROUP BY
Hard
πŸ”’
πŸ”’
Consecutive Activity Pattern
Find users with consecutive order streak.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Median Salary
Find median salary of employees.
WINDOW FUNCTIONSTATISTICSAGGREGATION
Hard
πŸ”’
πŸ”’
Increasing Sales Trend
Find products with increasing sales trend.
WINDOW FUNCTIONTRENDAGGREGATION
Hard
πŸ”’
πŸ”’
Order Rank per User
Rank orders per user by total.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Top City by Revenue
Find city with highest total revenue.
JOINGROUP BYORDER BY
Hard
πŸ”’
πŸ”’
Users Above Avg Order Spend
Find users whose avg order value exceeds overall avg.
HAVINGSUBQUERYAGGREGATION
Hard
πŸ”’
πŸ”’
Highest Profit Margin Products
Find products with highest (price-cost) margin.
CALCULATIONORDER BYANALYSIS
Hard
πŸ”’
πŸ”’
Salary Percentile
Assign percentile rank to salaries.
WINDOW FUNCTIONPERCENTILERANKING
Hard
πŸ”’
πŸ”’
Order Difference from Previous
Find difference between current and previous order.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
Department Salary Distribution
Find count of employees in salary buckets.
CASEGROUP BYAGGREGATION
Hard
πŸ”’
πŸ”’
Top Product per Day
Find most sold product each day.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Max Gap Between Orders
Find max gap in days between orders per user.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Order Rank Percent
Find percent rank of each order.
WINDOW FUNCTIONPERCENTILERANKING
Hard
πŸ”’
πŸ”’
Running Salary Total
Running total of salary by hire date.
WINDOW FUNCTIONRUNNING TOTALANALYTICS
Hard
πŸ”’
πŸ”’
Longest Order Streak
Find users with longest consecutive order streak.
AGGREGATIONRANKINGANALYSIS
Hard
πŸ”’
πŸ”’
Products With Zero Sales
Find products that never sold.
JOINANTI JOINFILTER
Hard
πŸ”’
πŸ”’
Cumulative Revenue Percentage
Find cumulative revenue percentage.
WINDOW FUNCTIONPERCENTAGERUNNING TOTAL
Hard
πŸ”’
πŸ”’
Company Salary Rank
Rank employees by salary globally.
WINDOW FUNCTIONRANKINGORDER
Hard
πŸ”’
πŸ”’
Daily Revenue Change
Find change in revenue day to day.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Top 10 Percent Products
Find products in top 10% by price.
WINDOW FUNCTIONNTILERANKING
Hard
πŸ”’
πŸ”’
Salary vs Avg Difference
Find difference between employee salary and avg.
WINDOW FUNCTIONAGGREGATIONANALYTICS
Hard
πŸ”’
πŸ”’
7-Day Rolling Revenue
Calculate 7-day rolling revenue.
WINDOW FUNCTIONROLLING WINDOWAGGREGATION
Hard
πŸ”’
πŸ”’
Top 2 Products by Revenue per Category
Find top 2 products by total revenue in each category.
WINDOW FUNCTIONPARTITIONAGGREGATION
Hard
πŸ”’
πŸ”’
Users with Increasing Order Values
Find users whose each order total is higher than previous one.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Top 10% Salaries
Find employees in top 10% salary bracket.
WINDOW FUNCTIONNTILERANKING
Hard
πŸ”’
πŸ”’
Median Order Value
Find median value of order totals.
WINDOW FUNCTIONSTATISTICSAGGREGATION
Hard
πŸ”’
πŸ”’
Max Consecutive Gap per User
Find max gap between consecutive orders per user.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Products with Consistent Sales
Find products sold every month.
GROUP BYDATEAGGREGATION
Hard
πŸ”’
πŸ”’
Cumulative Spend per User
Calculate cumulative spend per user over time.
WINDOW FUNCTIONPARTITIONRUNNING TOTAL
Hard
πŸ”’
πŸ”’
Dense Rank Salary per Department
Assign dense rank of salary within each department.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Top User per Country by Spend
Find user with highest total spend per country.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Day-over-Day Revenue Growth
Calculate daily revenue growth percentage.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Top 3 Users per Country
Find top 3 users per country by order count.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Second Highest Salary per Department
Find employees with second highest salary in each department.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Highest Order per Day
Find highest value order each day.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Order Range per User
Find difference between max and min order per user.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Top Rated Products
Find products with highest average rating.
GROUP BYORDER BYAGGREGATION
Hard
πŸ”’
πŸ”’
Top Revenue Orders
Find orders contributing to top 20% revenue.
WINDOW FUNCTIONNTILERANKING
Hard
πŸ”’
πŸ”’
Running Average Salary
Calculate running average salary by hire date.
WINDOW FUNCTIONRUNNING AVERAGEANALYTICS
Hard
πŸ”’
πŸ”’
User Lifecycle Duration
Find difference between first and last order per user.
GROUP BYDATEANALYSIS
Hard
πŸ”’
πŸ”’
Revenue Rank per Category
Rank products by revenue within category.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Cumulative Order Count per User
Find cumulative order count per user over time.
WINDOW FUNCTIONPARTITIONRUNNING TOTAL
Hard
πŸ”’
πŸ”’
Top 5 Products by Revenue
Find top 5 products based on total revenue globally.
GROUP BYAGGREGATIONORDER BY
Hard
πŸ”’
πŸ”’
Users Ordering Every Month
Find users who placed at least one order every month.
GROUP BYDATEHAVING
Hard
πŸ”’
πŸ”’
Top Salary Differences
Find employees with largest salary difference compared to previous.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
Orders with Multiple Payments
Find orders that have more than one payment record.
GROUP BYHAVINGDATA QUALITY
Hard
πŸ”’
πŸ”’
Highest Margin per Category
Find product with highest profit margin in each category.
WINDOW FUNCTIONPARTITIONCALCULATION
Hard
πŸ”’
πŸ”’
Top Users in Last 30 Days
Find users with most orders in last 30 days.
DATEGROUP BYORDER BY
Hard
πŸ”’
πŸ”’
Cumulative Spend % per User
Find cumulative percentage of spend per user.
WINDOW FUNCTIONPARTITIONPERCENTAGE
Hard
πŸ”’
πŸ”’
Longest Tenure Employees
Find employees with longest tenure.
DATEORDER BYCALCULATION
Hard
πŸ”’
πŸ”’
Products Not Sold Last Month
Find products not sold in last month.
JOINDATEANTI JOIN
Hard
πŸ”’
πŸ”’
Max Items per User
Find order with max item_count per user.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Users with Decreasing Orders
Find users whose order values decrease over time.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Salary Buckets Ranking
Divide employees into 4 salary buckets.
WINDOW FUNCTIONNTILERANKING
Hard
πŸ”’
πŸ”’
Top 10% Users by Spend
Find users in top 10% by total spend.
WINDOW FUNCTIONGROUP BYRANKING
Hard
πŸ”’
πŸ”’
Max Sales Growth Products
Find products with highest growth between consecutive sales.
WINDOW FUNCTIONAGGREGATIONTREND
Hard
πŸ”’
πŸ”’
Cumulative Max Order
Find cumulative max order total over time.
WINDOW FUNCTIONRUNNING MAXANALYTICS
Hard
πŸ”’
πŸ”’
Users with Max Gap
Find user with largest gap between orders.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Salary vs Dept Avg
Find difference between salary and department average.
WINDOW FUNCTIONPARTITIONANALYTICS
Hard
πŸ”’
πŸ”’
7-Day Rolling Orders Count
Find rolling 7-day order count.
WINDOW FUNCTIONROLLING WINDOWAGGREGATION
Hard
πŸ”’
πŸ”’
Top Rated per Category
Find highest rated product in each category.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
User Spend Percentile
Assign percentile rank to users based on spend.
WINDOW FUNCTIONGROUP BYPERCENTILE
Hard
πŸ”’
πŸ”’
Top Order per User Each Month
Find highest value order for each user in each month.
WINDOW FUNCTIONPARTITIONDATE
Hard
πŸ”’
πŸ”’
Users with Consistent Monthly Growth
Find users whose monthly spending increases every month.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Products with Review Growth
Find products with highest increase in reviews over time.
WINDOW FUNCTIONAGGREGATIONTREND
Hard
πŸ”’
πŸ”’
Users Ordering Weekly
Find users who placed orders at least once every 7 days.
WINDOW FUNCTIONLAGDATE
Hard
πŸ”’
πŸ”’
Managers Earning More Than Subordinates
Find managers whose salary is greater than all their subordinates.
SELF JOINGROUP BYLOGIC
Hard
πŸ”’
πŸ”’
Daily Revenue Percentile
Find percentile of each order within its day.
WINDOW FUNCTIONPARTITIONPERCENTILE
Hard
πŸ”’
πŸ”’
Users with Most Product Diversity
Find users who ordered the highest number of distinct products.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Repeat Purchase Products
Find products most frequently reordered by same users.
GROUP BYJOINANALYSIS
Hard
πŸ”’
πŸ”’
Max Revenue Streak
Find longest streak of increasing revenue days.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Highest Lifetime Value Users
Find users with highest lifetime total spend.
GROUP BYAGGREGATIONORDER BY
Hard
πŸ”’
πŸ”’
3-Day Increasing Revenue Streak
Find days where revenue increased for 3 consecutive days.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Longest Consecutive Order Days
Find users with longest consecutive daily ordering streak.
WINDOW FUNCTIONPATTERNGROUP BY
Hard
πŸ”’
πŸ”’
Max MoM Revenue Growth
Find products with highest month-over-month revenue growth.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Employee Hierarchy Depth
Find maximum depth of employee hierarchy.
CTERECURSIONHIERARCHY
Hard
πŸ”’
πŸ”’
Churned Users Detection
Find users who have not ordered in last 90 days.
GROUP BYDATEANALYTICS
Hard
πŸ”’
πŸ”’
Running Median Orders
Calculate running median of order totals.
WINDOW FUNCTIONSTATISTICSADVANCED
Hard
πŸ”’
πŸ”’
Daily Sales Contribution
Find each product’s contribution to daily sales.
WINDOW FUNCTIONPARTITIONPERCENTAGE
Hard
πŸ”’
πŸ”’
Max Hiring Gap
Find largest gap between consecutive hires.
WINDOW FUNCTIONLAGDATE
Hard
πŸ”’
πŸ”’
Peak Revenue Point
Find order date where cumulative revenue is highest.
WINDOW FUNCTIONRUNNING TOTALORDER BY
Hard
πŸ”’
πŸ”’
Users with Highest Growth Rate
Find users with highest growth between consecutive orders.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Stable Rating Products
Find products with minimal variance in rating.
AGGREGATIONSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Peak Revenue Day
Find the day with highest total revenue.
GROUP BYORDER BYAGGREGATION
Hard
πŸ”’
πŸ”’
Most Frequent Buyers
Find users with smallest average gap between orders.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Most Frequently Ordered Products
Find products appearing in most orders.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Running Minimum Order
Find running minimum order total.
WINDOW FUNCTIONRUNNING MINANALYTICS
Hard
πŸ”’
πŸ”’
Department Change Detection
Detect employees who changed departments.
WINDOW FUNCTIONLAGANALYSIS
Hard
πŸ”’
πŸ”’
High Activity Burst Users
Find users with most orders in shortest time span.
GROUP BYDATEANALYSIS
Hard
πŸ”’
πŸ”’
Daily Percent Change
Calculate percent change in daily revenue.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Sales Volatility Products
Find products with highest variance in sales.
AGGREGATIONSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Loyalty Score Users
Define loyalty as number of orders * avg order value and find top users.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Max Orders in Rolling 30 Days
Find users with maximum number of orders in any 30-day rolling window.
SELF JOINDATEAGGREGATION
Hard
πŸ”’
πŸ”’
Top Revenue Product per Day
Find product contributing highest revenue each day.
WINDOW FUNCTIONPARTITIONGROUP BY
Hard
πŸ”’
πŸ”’
Salary Gap from Manager
Find employees with highest salary difference compared to manager.
SELF JOINCALCULATIONORDER BY
Hard
πŸ”’
πŸ”’
Fastest Growing Spend
Find users with highest increase in cumulative spend.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
Top Products Last 3 Months
Find products with highest revenue in last 3 months.
JOINDATEGROUP BY
Hard
πŸ”’
πŸ”’
Longest Increasing Order Streak
Find longest streak of increasing order totals.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Top Users per Week
Find users with highest orders each week.
WINDOW FUNCTIONDATEGROUP BY
Hard
πŸ”’
πŸ”’
Max Revenue Difference
Find difference between max and min revenue per product.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Highest Salary Growth
Find employees with highest growth compared to previous record.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
User Contribution %
Find each user contribution to total revenue.
WINDOW FUNCTIONGROUP BYPERCENTAGE
Hard
πŸ”’
πŸ”’
Most Loyal Buyer per Product
Find user who bought each product most frequently.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Peak Order Count Point
Find point where cumulative order count is highest.
WINDOW FUNCTIONRUNNING TOTALORDER BY
Hard
πŸ”’
πŸ”’
Users with Largest Orders
Find users with highest average products per order.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Products with Diverse Buyers
Find products bought by most unique users.
JOINGROUP BYAGGREGATION
Hard
πŸ”’
πŸ”’
Week-over-Week Growth
Calculate weekly revenue growth.
WINDOW FUNCTIONDATEAGGREGATION
Hard
πŸ”’
πŸ”’
Department Median Salary
Find median salary per department.
WINDOW FUNCTIONPARTITIONSTATISTICS
Hard
πŸ”’
πŸ”’
Most Active Users
Find users with most distinct order days.
GROUP BYDISTINCTANALYSIS
Hard
πŸ”’
πŸ”’
Daily Sales Variance
Find products with highest daily sales variance.
AGGREGATIONSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Max Shipping Delay
Find orders with maximum shipping delay.
DATECALCULATIONORDER BY
Hard
πŸ”’
πŸ”’
Most Profitable Users
Find users generating highest profit (price - cost).
JOINGROUP BYCALCULATION
Hard
πŸ”’
πŸ”’
Max Orders in a Single Day per User
Find users who placed the highest number of orders in a single day.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Highest Profit per Order Product
Find product generating highest profit per single order.
JOINCALCULATIONGROUP BY
Hard
πŸ”’
πŸ”’
Fastest Repeat Buyers
Find users with smallest gap between two consecutive orders.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
Highest Item Density Orders
Find orders with highest items per value ratio.
CALCULATIONORDER BYANALYSIS
Hard
πŸ”’
πŸ”’
Managers with Most Subordinates
Find managers with highest number of direct reports.
SELF JOINGROUP BYAGGREGATION
Hard
πŸ”’
πŸ”’
Users with Longest Avg Gap
Find users with highest average gap between orders.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Highest Avg Sales per Order
Find products with highest average quantity per order.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Largest Discount Impact Orders
Find orders where discount percentage is highest.
CALCULATIONORDER BYANALYSIS
Hard
πŸ”’
πŸ”’
Most Consistent Buyers
Find users with lowest variance in order values.
AGGREGATIONSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Revenue per Review
Find products generating highest revenue per review.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Orders to Spend Ratio
Find users with highest number of orders relative to total spend.
GROUP BYCALCULATIONANALYSIS
Hard
πŸ”’
πŸ”’
Highest Monthly Sales Spike
Find products with biggest jump in monthly sales.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Salary Z-Score
Calculate z-score of each employee salary.
WINDOW FUNCTIONSTATISTICSANALYTICS
Hard
πŸ”’
πŸ”’
Max Items per Day per User
Find order with highest items per user each day.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Consistent Frequency Users
Find users with least variation in days between orders.
WINDOW FUNCTIONSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Max Daily Sales Growth
Find products with highest growth between consecutive days.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
High Variance Buyers
Find users with highest variance in order values.
GROUP BYSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Cumulative Rank per User
Assign rank to each order cumulatively per user.
WINDOW FUNCTIONPARTITIONRANKING
Hard
πŸ”’
πŸ”’
Monthly Sales Volatility
Find products with highest variance in monthly revenue.
GROUP BYSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Fastest Growth in Orders Count
Find users with highest increase in number of orders month over month.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Increasing Salary Trend
Find employees whose salary consistently increases over time.
WINDOW FUNCTIONLAGPATTERN
Hard
πŸ”’
πŸ”’
Value Density Orders
Find orders with highest value per item.
CALCULATIONORDER BYANALYSIS
Hard
πŸ”’
πŸ”’
Consistent Daily Sales Products
Find products with lowest variance in daily sales.
GROUP BYSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Early Engagement Users
Find users with most orders within first 7 days of first order.
JOINDATEGROUP BY
Hard
πŸ”’
πŸ”’
Most Frequent Products per Day
Find product ordered most frequently each day.
WINDOW FUNCTIONGROUP BYPARTITION
Hard
πŸ”’
πŸ”’
Avg Order Growth Users
Find users with highest average growth in order value.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Cumulative Density Orders
Find cumulative average order value over time.
WINDOW FUNCTIONRUNNING AVERAGEANALYTICS
Hard
πŸ”’
πŸ”’
Repeat Customer Products
Find products with highest number of repeat customers.
GROUP BYJOINANALYSIS
Hard
πŸ”’
πŸ”’
Relative Salary Rank
Assign normalized rank between 0 and 1 for salaries.
WINDOW FUNCTIONRANKINGANALYTICS
Hard
πŸ”’
πŸ”’
Max Order in 7-Day Window
Find max order total in rolling 7-day window.
WINDOW FUNCTIONROLLING WINDOWAGGREGATION
Hard
πŸ”’
πŸ”’
Highest Avg Daily Revenue Users
Find users with highest average daily revenue.
GROUP BYAGGREGATIONANALYSIS
Hard
πŸ”’
πŸ”’
Longest Sales Streak per Product
Find products with longest consecutive days of sales.
WINDOW FUNCTIONPATTERNGROUP BY
Hard
πŸ”’
πŸ”’
Salary Outliers Detection
Find employees whose salary is more than 2x average salary.
SUBQUERYFILTERANALYSIS
Hard
πŸ”’
πŸ”’
Revenue per Item Efficiency
Find orders with highest revenue per item.
CALCULATIONORDER BYANALYSIS
Hard
πŸ”’
πŸ”’
Most Orders in First Month
Find users who placed most orders in their first month.
JOINDATEGROUP BY
Hard
πŸ”’
πŸ”’
Category Revenue Leaders
Find category contributing highest revenue overall.
JOINGROUP BYAGGREGATION
Hard
πŸ”’
πŸ”’
Largest Order Amount Jump
Find largest jump between consecutive order totals.
WINDOW FUNCTIONLAGANALYTICS
Hard
πŸ”’
πŸ”’
Highest Repeat Purchase Rate
Find users with highest ratio of repeat orders.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Above Median Salary Employees
Find employees earning above median salary.
WINDOW FUNCTIONSTATISTICSSUBQUERY
Hard
πŸ”’
πŸ”’
User Cumulative Contribution
Find cumulative contribution percentage per user over time.
WINDOW FUNCTIONPARTITIONPERCENTAGE
Hard
πŸ”’
πŸ”’
Monthly Spend Variance Users
Find users with highest variance in monthly spend.
GROUP BYSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Max Product Orders in 7-Day Window
Find products with highest order count in any rolling 7-day window.
SELF JOINDATEAGGREGATION
Hard
πŸ”’
πŸ”’
Salary Ratio to Department Avg
Find employees with highest ratio of salary to department average.
WINDOW FUNCTIONPARTITIONCALCULATION
Hard
πŸ”’
πŸ”’
Max Growth Streak per User
Find longest increasing order value streak per user.
WINDOW FUNCTIONPATTERNGROUP BY
Hard
πŸ”’
πŸ”’
Monthly Profit Growth Products
Find products with highest profit growth month over month.
WINDOW FUNCTIONJOINAGGREGATION
Hard
πŸ”’
πŸ”’
Max Orders in 14-Day Window
Find users with highest order count in any 14-day period.
SELF JOINDATEAGGREGATION
Hard
πŸ”’
πŸ”’
Peak Revenue Point per User
Find order date where cumulative revenue peaks per user.
WINDOW FUNCTIONPARTITIONANALYTICS
Hard
πŸ”’
πŸ”’
Balanced Salary Departments
Find departments with lowest salary variance.
GROUP BYSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Highest Retention Products
Find products with most repeat buyers over time.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Top Revenue Week
Find week with highest total revenue.
DATEGROUP BYAGGREGATION
Hard
πŸ”’
πŸ”’
Orders per Active Day
Find users with highest ratio of total orders to active days.
GROUP BYDISTINCTANALYSIS
Hard
πŸ”’
πŸ”’
Weekly Growth Rate Products
Find products with highest week-over-week sales growth rate.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Salary % Difference from Dept Avg
Calculate percentage difference of employee salary from department average.
WINDOW FUNCTIONPARTITIONCALCULATION
Hard
πŸ”’
πŸ”’
Highest Daily Growth Orders
Find order days with highest increase in revenue compared to previous day.
WINDOW FUNCTIONLAGAGGREGATION
Hard
πŸ”’
πŸ”’
Max Product Variety per Order
Find users with highest average number of distinct products per order.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Sales per Active Day Products
Find products with highest average sales per active day.
JOINGROUP BYANALYSIS
Hard
πŸ”’
πŸ”’
Highest Salary Growth Rate
Find employees with highest percentage increase in salary.
WINDOW FUNCTIONLAGCALCULATION
Hard
πŸ”’
πŸ”’
Max Density in 5-Day Window
Find highest average order value in rolling 5-day window.
WINDOW FUNCTIONROLLING WINDOWAGGREGATION
Hard
πŸ”’
πŸ”’
Balanced Spending Users
Find users with lowest variance in monthly spend.
GROUP BYSTATISTICSANALYSIS
Hard
πŸ”’
πŸ”’
Top Revenue Contribution Products
Find products contributing highest percentage to total revenue.
WINDOW FUNCTIONGROUP BYPERCENTAGE
Hard
πŸ”’

Want all 389 challenges?

Upgrade to Premium for full access, AI hints and PostgreSQL mode.

Master SQL for Technical Interviews

SQL is the most in-demand data skill for analyst, data engineer, and backend developer roles. Whether you are preparing for a FAANG data interview, a business analyst assessment, or your first SQL screening round, consistent hands-on SQL practice is what separates candidates who pass from those who don't. Every SQL interview question you solve here runs against a real database β€” not a toy example β€” so the skills transfer directly to your next interview.

Our SQL practice challenges are grouped into three difficulty levels so you can build confidence systematically. Start with Easy SQL exercises to solidify the foundations, progress to Medium SQL problems that cover the core of most interviews, then tackle the Hard SQL challenges that involve advanced patterns used at senior levels.

Easy SQL Challenges(104 challenges)

Core syntax: SELECT, WHERE, ORDER BY, GROUP BY, HAVING, COUNT, SUM, AVG. Perfect for beginners or anyone returning to SQL after a break. These are the foundations every SQL interview tests.

Medium SQL Challenges(85 challenges)

Intermediate SQL: INNER, LEFT, RIGHT and FULL OUTER JOINs, subqueries, CASE WHEN expressions, string functions, and date arithmetic. The bread and butter of analyst and data engineer interviews.

Hard SQL Challenges(200 challenges)

Advanced SQL: window functions (ROW_NUMBER, RANK, LAG, LEAD), Common Table Expressions (CTEs), recursive queries, cohort analysis, RFM segmentation, and rolling aggregations.

SQL Interview Questions You Will Practice

All SQL practice problems run against a shared e-commerce database with tables for users, orders, products, and sessions β€” the exact schema type used in real data take-home tests and live SQL interview rounds. Topics covered across all 389 SQL challenges include:

  • SELECT, WHERE, ORDER BY, LIMIT
  • GROUP BY, HAVING, aggregations
  • INNER, LEFT, RIGHT, FULL OUTER JOINs
  • Subqueries and correlated subqueries
  • CASE WHEN expressions
  • String and date functions
  • Window functions: ROW_NUMBER, RANK
  • LAG, LEAD, NTILE, PERCENT_RANK
  • CTEs and recursive queries
  • Running totals and rolling averages
  • Cohort retention analysis
  • RFM customer segmentation

How SQL Practice Challenges Work

Pick any challenge from the list above and write your SQL query in the live editor. Run it against the real database and see your results instantly β€” no setup, no local database, no installation required. Each challenge includes a hint if you get stuck, and a fully worked solution to compare your approach against. The fastest way to improve at SQL is to write real queries against real data every day.

After practising with challenges, test your readiness with our SQL Skill Test β€” a timed 15-question assessment that mirrors a real SQL interview round and generates a shareable certificate when you pass. You can also explore the SQL Playground to run any free-form query on the same database.

Frequently Asked Questions

Are these SQL challenges free?+

Yes β€” the first 30 SQL challenges are completely free with no signup required. Create a free account to track your progress. Premium unlocks all 389 challenges including advanced window function and CTE problems.

What SQL dialect is used?+

The free SQL challenges use SQLite syntax which is compatible with standard SQL. Premium mode supports PostgreSQL β€” the dialect used most frequently in real data engineering interviews.

Are these challenges good for SQL interview preparation?+

Yes. Every challenge is modelled on real SQL interview questions asked at tech companies, analytics teams, and data engineering roles. The Medium and Hard tiers specifically target the JOIN, window function, and CTE patterns that appear most in interviews.

How do I get started with SQL practice?+

Click any challenge above to open it in the live SQL editor. No installation needed. If you're new to SQL, start with the Easy challenges and work your way up. Use the hint button if you get stuck.