HomePractice
OFFICIAL CURATED ARENA

</>SQL Practice Arena

Curated ANSI SQL practice challenges across Window Functions, CTEs, complex Joins, and aggregations.

Your Progress
0 / 106 Solved
#01Easy
Basic Queries

Select Product Name and Price from Inventory

#SELECT#Projection
#02Easy
Filtering & Sorting

Find Customer Orders Exceeding 500 Dollars

#WHERE#Filtering
#03Easy
Filtering & Sorting

Find All Unique Customer Cities

#DISTINCT#Deduplication
#04Easy
Filtering & Sorting

Sort Employees by Salary and Name

#ORDER BY#Sorting
#05Easy
Filtering & Sorting

Find the Single Most Expensive Product

#LIMIT#Top N
#06Easy
Filtering & Sorting

Find Employees with Salary Between 80,000 and 90,000

#BETWEEN#Range Filter
#07Easy
Filtering & Sorting

Find Employees in HR, IT, or Engineering Departments

#IN#Set Membership
#08Easy
String Manipulation

Find Employees Whose Names Start with 'A'

#LIKE#Wildcards
#09Easy
Data Quality

Find Employees Without an Assigned Department

#IS NULL#Null Handling
#10Easy
Aggregation & Grouping

Count Total Number of Employees

#COUNT#Aggregation
#11Easy
Aggregation & Grouping

Calculate Total Salary Payroll of All Employees

#SUM#Aggregation
#12Easy
Aggregation & Grouping

Calculate Company-Wide Average Employee Salary

#AVG#Mean Calculation
#13Easy
Aggregation & Grouping

Find Minimum and Maximum Employee Salaries

#MIN#MAX
#14Easy
Conditional Logic

Categorize Employees into Compensation Tiers

#CASE#Salary Tier
#15Easy
String Manipulation

Format Employee Name and Department into Single Label

#CONCAT#Formatting
#16Easy
String Manipulation

Extract First Three Characters of Employee Name

#SUBSTRING#Extraction
#17Easy
String Manipulation

Find Employees with Names Longer than Four Characters

#LENGTH#Validation
#18Easy
String Manipulation

Format Employee Names to Uppercase and Departments to Lowercase

#UPPER#LOWER
#19Easy
Numeric & Math

Round Employee Salaries to One Decimal Place

#ROUND#Precision
#20Easy
Date & Time

Select Order ID and Date Sorted by Order Date

#STRFTIME#Date Formatting
#21Easy
Aggregation & Grouping

Count Total Employees in Each Department

#GROUP BY#Headcount
#22Easy
Aggregation & Grouping

Find Departments with More Than One Employee

#HAVING#Threshold Filter
#23Easy
Basic Queries

Select Employee Names with Column Alias employee_name

#AS#Aliasing
#24Easy
Data Quality

Replace Missing Employee Departments with 'Unassigned'

#COALESCE#Default Values
#25Easy
Joins & Set Operations

Retrieve Employee Names Along with Department Names

#JOIN#Relational Mapping
#26Medium
Joins & Set Operations

Inner Join Employees and Departments to Report Salaries

#INNER JOIN#Relational
#27Medium
Joins & Set Operations

Find Customers Who Have Never Placed an Order

#LEFT JOIN#Anti-Join
#28Medium
Joins & Set Operations

List All Departments and Matching Employees Using Left Join

#LEFT JOIN#Department Roster
#29Medium
Joins & Set Operations

Find Each Employee and Their Direct Manager Name

#SELF JOIN#Manager Hierarchy
#30Medium
Joins & Set Operations

Generate Cartesian Cross Product of Employees and Departments

#CROSS JOIN#Cartesian Product
#31Medium
Joins & Set Operations

Combine Distinct Names from Employees and Contractors

#UNION#Set Union
#32Medium
Joins & Set Operations

Combine All Names from Employees and Contractors Including Duplicates

#UNION ALL#Full Union
#33Medium
Subqueries & CTEs

Find Employees Earning Higher Than Average Company Salary

#Subquery#AVG Filter
#34Medium
Subqueries & CTEs

Find Customers with At Least One Order Using EXISTS

#EXISTS#Semi-Join
#35Medium
Subqueries & CTEs

Find Customers with No Orders Using NOT EXISTS

#NOT EXISTS#Anti-Join
#36Medium
Subqueries & CTEs

Find High Earners and Their Departments Using Common Table Expression

#CTE#WITH Clause
#37Medium
Window Functions

Assign Row Numbers to Employees by Salary within Department

#ROW_NUMBER#Ordering
#38Medium
Window Functions

Rank Employees by Salary within Department Using RANK

#RANK#Ties with Gaps
#39Medium
Window Functions

Rank Employees by Salary within Department Without Gaps Using DENSE_RANK

#DENSE_RANK#Dense Ranking
#40Medium
Window Functions

Compare Employee Salary with Preceding Colleague Using LAG

#LAG#Preceding Value
#41Medium
Window Functions

Compare Employee Salary with Subsequent Colleague Using LEAD

#LEAD#Following Value
#42Medium
Window Functions

Calculate Running Total of Sales Ordered by Date

#SUM OVER#Running Total
#43Medium
Window Functions

Find Top 2 Highest Paid Employees in Each Department

#ROW_NUMBER#Top N
#44Medium
Data Quality

Find Duplicate User Emails in Accounts Table

#HAVING#Duplicate Detection
#45Medium
Data Quality

Deduplicate User Records by Email and Name

#DISTINCT#Deduplication
#46Medium
Business Analytics

Calculate Total Spend per Customer from Orders

#SUM#Customer LTV
#47Medium
Time-Series & Analytics

Aggregate Total Sales Revenue by Month

#STRFTIME#Monthly Revenue
#48Medium
String Manipulation

Extract Category Attribute from JSON Logs

#JSON#json_extract
#49Medium
Business Analytics

Pivot Department Sales by Year 2023 and 2024

#Conditional SUM#Pivoting
#50Medium
Joins & Set Operations

Reconcile Two Tables Using Full Outer Join

#FULL OUTER JOIN#COALESCE
#51Hard
Subqueries & CTEs

Find Highest-Paid Employee in Each Department

#MAX#Department Top Earner
#52Hard
Window Functions

Top 3 Highest-Paid Employees per Department

#DENSE_RANK#Top 3 per Group
#53Hard
Window Functions

Identify Session Start Boundaries from Clickstream Events

#LAG#Sessionization
#54Hard
Gaps & Islands

Find Contiguous Active User Login Streaks

#Gaps & Islands#Streak Detection
#55Hard
Data Warehousing

Lookup Slowly Changing Company Dimension by Effective Date

#SCD Type 2#Point-in-Time
#56Hard
Data Engineering

Filter Incremental Records Past Watermark Timestamp

#Watermark#Incremental Load
#57Hard
Data Quality

Identify Employee Records Failing Quality Check Rules

#Data Quality#Validation
#58Hard
Time-Series & Analytics

Group User Signups into Monthly Acquisition Cohorts

#Cohorts#STRFTIME
#59Hard
Business Analytics

Calculate Sales Performance Metrics by Geographic Region

#KPIs#Aggregates
#60Hard
Data Engineering

Standardize and Clean Raw Staging User Records

#TRIM#UPPER#Data Cleansing
#61Medium
Window Functions

Second-Highest Salary in Each Department

#DENSE_RANK#Runner-Up#Window Functions
#62Medium
Subqueries & Joins

Employees Earning Above Department Average

#AVG#Subquery#Benchmark
#63Medium
Self Joins

Employees Out-Earning Their Direct Supervisors

#SELF JOIN#Manager Hierarchy
#64Medium
Window Functions

Third-Highest Company Salary Without Paging

#DENSE_RANK#DISTINCT#No Limit
#65Hard
Window Functions

Top 10 Percent Highest Earners per Department

#CUME_DIST#Top Decile#Percentiles
#66Medium
Window Functions

Quartile Salary Distribution by Department

#NTILE#Quartiles#Bucketing
#67Hard
Window Functions

Employee with Salary Closest to Department Average

#AVG#ABS Difference#Window Functions
#68Hard
Correlated Subqueries

Employees Out-Earning at Least Three Department Peers

#Correlated Subquery#COUNT#Filtering
#69Medium
Deduplication

Keep Most Recent Customer Record by Timestamp

#ROW_NUMBER#Latest Timestamp#Deduplication
#70Medium
Deduplication

Identify Duplicate Customer Profiles on Composite Key

#Composite Key#ROW_NUMBER#Deduplication
#71Medium
Window Functions

Audit Customer Email Changes Over Time

#LAG#History Tracking#Audit Log
#72Medium
Deduplication

Extract Latest Customer Status from History

#ROW_NUMBER#Status History#Latest State
#73Hard
Window Functions

Detect Account Reactivations from Closed to Active

#State Transitions#Reactivation#HAVING
#74Medium
Aggregation & Grouping

Find First and Most Recent Record per Customer

#MIN_BY#MAX_BY#Lifecycle Snapshot
#75Medium
Deduplication

Filter Duplicate Records Retaining Minimum ID

#Self Join#Min ID Retention#Deduplication
#76Medium
Data Quality

Detect Conflicting Status Changes on Same Date

#GROUP BY#HAVING#Audit Log
#77Medium
Aggregation & Joins

Find Managers with More Than Five Direct Reports

#GROUP BY#HAVING#Hierarchy
#78Medium
Correlated Subqueries

Detect Salary Ties Within the Same Department

#EXISTS#Salary Ties#Subqueries
#79Medium
Set Operations & Joins

Customers Who Purchased Product A but Never Product B

#NOT EXISTS#Market Basket#Set Difference
#80Hard
Relational Division

Customers Who Bought Every Product in a Category

#Relational Division#HAVING#COUNT DISTINCT
#81Hard
Business Analytics

Products Purchased by 80 Percent of Active Customers

#CTE#Market Penetration#Ratio Analysis
#82Medium
Time-Series

Identify Active Customers Ordering Every Month of the Year

#DATE_TRUNC#12-Month Coverage#Customer Loyalty
#83Medium
Business Analytics

High-Value Customers Spending Above Global Average

#LTV#CTE#Above Average
#84Medium
Aggregation & Subqueries

Departments with Average Salary Exceeding Company Average

#HAVING#AVG#Benchmark
#85Hard
Gaps & Islands

Find Users with 3 Consecutive Days Login Streak

#Gaps & Islands#Login Streaks#Window Functions
#86Hard
Gaps & Islands

Longest Consecutive Daily Login Streak per User

#Gaps & Islands#MAX Streak#Window Functions
#87Hard
Time-Series

Customers with Consecutive 3-Month Purchasing Cadence

#Gaps & Islands#Cadence#Month Math
#88Medium
Time-Series

Calculate Days Elapsed Between First and Second Purchase

#Repeat Purchase#Date Difference#ROW_NUMBER
#89Medium
Financial Analytics

Calculate Month-over-Month (MoM) Revenue Growth Rate

#LAG#MoM Growth#Percentage Change
#90Hard
Time-Series

Compute 7-Day Trailing Rolling Average Revenue

#Rolling Average#RANGE BETWEEN#Window Functions
#91Hard
Time-Series

Calculate 30-Day Trailing Rolling Spend per Customer

#Rolling Sum#RANGE BETWEEN#Customer Spend
#92Medium
Time-Series

Customers Making Repeat Purchase Within 30 Days

#Repeat Conversion#Date Math#Window Functions
#93Medium
Gaps & Islands

Identify Inactive Transaction Periods Exceeding 30 Days

#LEAD#Dormancy Gaps#Customer Inactivity
#94Hard
Gaps & Islands

Detect Employees Absent for 3 or More Consecutive Days

#Gaps & Islands#Attendance#Absence Tracking
#95Hard
Gaps & Islands

Continuous Periods of High-Volume Daily Sales Exceeding 100K

#Gaps & Islands#Sales Waves#Revenue Spikes
#96Easy
Aggregation & Grouping

Customer Activity Span: First Date, Last Date, and Active Days

#MIN/MAX#COUNT DISTINCT#Customer Lifecycle
#97Hard
Business Analytics

Top 3 Products by Revenue for Each Month

#DENSE_RANK#Monthly Top Products#E-commerce
#98Medium
Business Analytics

Top 2 Customers by Revenue for Each Month

#DENSE_RANK#Top Spenders#Monthly Customers
#99Hard
Time-Series

Customers with Increasing Monthly Spending for 3 Consecutive Months

#Gaps & Islands#Spending Growth#Monthly Trends
#100Medium
Customer Analytics

Identify Immediately Churned Customers from Last Month

#NOT EXISTS#Churn Analysis#Cohort Inactivity
#101Hard
Gaps & Islands

Identify Users with 7-Day Continuous Login Streak

#Gaps & Islands#7-Day Streak#Window Functions
#102Medium
Financial Analytics

Calculate Year-over-Year (YoY) Revenue Growth Rate

#YoY Growth#EXTRACT#LAG
#103Hard
Gaps & Islands

Identify Continuous Active Periods for Each User

#Gaps & Islands#User Activity#Streak Detection
#104Hard
Cohort Analytics

Measure Customer Retention at Day-1, Day-7, and Day-30

#Cohort Retention#CROSS JOIN#Retention Curves
#105Hard
SaaS Metrics

Calculate Monthly Customer Repeat Rate Percentage

#Repeat Rate#LAG#Customer Retention
#106Medium
Executive Analytics

Top 10 Customers Revenue Concentration Share

#Revenue Share#Pareto Analysis#Window Functions