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.