99 hands-on SQL exercises, from SELECT and WHERE to window functions, CTEs and table design. Use them to learn SQL from scratch, get comfortable with JOINs and GROUP BY, or prepare for a data analyst, developer or QA interview.
Every problem comes with a real-world scenario, the table schema and a sample of the expected output. The easiest way to solve them is the online trainer SQL Arena: write a query in your browser, press Submit, and your answer is checked right away against hidden data. Nothing to install β every problem runs on PostgreSQL, and many also on MySQL and ClickHouse.
- Statement β a short work scenario: what to find and how to present it.
- Tables β columns, types, primary (π) and foreign (β) keys.
- Expected columns and sample output β the fields the checker expects and the first rows of a correct result.
- "Solve online" link β the problem in the trainer, with an editor, a sandbox with data and automatic checking.
There are no ready-made solutions here on purpose: a problem you peeked at teaches nothing. The trainer compares your query with the reference on data you cannot see and tells you what is off: extra rows, wrong columns, wrong order.
- Over-the-Counter Medications β easy
- Customers from Berlin β easy
- Platinum-Tier Members β easy
- Long-Haul Flights β easy
- Berlin Clubs β easy
- Premium Subscriptions β easy
- 5-Star Hotels β easy
- Rock Artists β easy
- Spacious Rooms β easy
- Festivals in 2024 β easy
- Endangered Species β easy
- Savanna Residents β easy
- Product Showcase: Rename the Columns β easy
- Products Under 1000 Rubles β easy
- Delivered Orders β easy
- Customer card: projection with aliases β easy
- Products from two warehouses β easy
- Catalog Without Archive β easy
- Warehouse shelf: SKU, weight and price under readable names β easy
- Drop Unrated Reviews, Replace Empty Comments β easy
- Monthly Sales Pulse β easy
- Listening Hours by Month β easy
- Store delivery scorecard β easy
- A Customer's First Digital Footprint β easy
- Duplicate Parcel Registrations β easy
- Purchase Frequency in an Audio App β easy
- Which Customers Need a Win-Back Campaign? β easy
- From KYC Submission to Approval β easy
- Most Read Books Lookup β easy
- Kotomarket monthly orders report β medium
- Top 3 categories by revenue β medium
- Average Salary of Employees by Departments for 2023 β medium
- Book Sales Split by Genre β medium
- Analysis of courier performance by delivered packages β medium
- Client Buying Behavior Study β medium
- Sales Split by Product Category β medium
- Box Office Revenue by Popular Genres β medium
- Most prolific authors with high ratings β medium
- Second-level shelves β easy
- One-to-one, one-to-many β easy
- Row fan-out after a JOIN β easy
- Comparable apartment pairs β easy
- Employees Shown with Their Departments β easy
- Popular vehicles with multiple bookings β easy
- Package delivery tracking by shipment codes β easy
- Top players with high average score β medium
- Analyzing Airline Route Profitability β medium
- High-Volume and Profitable Products β medium
- Most Active Authors by Published Articles Count β medium
- Overloaded Hospital Departments β medium
- Top hotel rooms by average rating and revenue β medium
- Top companies by average applicant review rating β medium
- Profitable room categories for the quarter β medium
- Doctors with the highest patient complexity β medium
- Analysis of insurance policy losses by region β medium
- Top farmers' yield by crops β medium
- Find the most expensive item β easy
- Pull orders from Russian customers only β easy
- Find orders bigger than average β easy
- Customers who already ordered something β easy
- Products that nobody bought β easy
- Show every customer's order count β easy
- Cheapest pick in every category β easy
- Parcel scans after the watermark β easy
- Documentary watchers β easy
- Top Bank Clients by Transaction Amount β hard
- Quarterly Performance of Sales Managers β hard
- Top Couriers by Deliveries with Urgency Priority β hard
- Employee Earnings Breakdown β hard
- Monthly Top Tracks in Playlists β hard
- Most-Played Artists Across Playlists β hard
- Student Performance Ranking by Department with Grade Dynamics β hard
- Revenue Month-on-Month Growth β hard
- Gaps between plays β easy
- Session-start flag in an online store β easy
- Neobank Operating Balance β easy
- Each Product's Share of Total Revenue via SUM() OVER () β medium
- Staff Salaries: How Far From the Average β medium
- Student Rating by Average Grade with Group Position β medium
- Crop Variety Yield Rankings by Plot β medium
- Genre Champions Among Library Readers β hard
- Payout Trends Across Insurance Policies β hard
- Gym Member Payment Momentum β hard
- Fleet Revenue Growth by Month β hard
- Monthly Box Office Peaks by Film β hard
- Rising Stars of the Travel Agency β hard
- Repeat Visit Intervals by Doctor β hard
- Discount on Action games β easy
- Seed a batch of test orders β easy
- Spring cleaning β drop everything unpinned β easy
- Save your first journal entry β easy
- Pin every January note for the new year β easy
- Add a test user β easy
- Drop the Departments Table β easy
- Add Email Column β easy
- Drop Salary Column β easy
- Rename Column name β easy
- Normalization: split a flat book catalog into authors + books (PK/FK) β medium
- Kotomarket: split an order into 3NF β medium
This repository holds 99 problems from the free part of the trainer. SQL Arena has more than 1,400: interview questions, a SQL course from scratch, courses on analytics, ClickHouse and Kafka, duels and a leaderboard.
Π ΡΡΡΠΊΠ°Ρ Π²Π΅ΡΡΠΈΡ β sql-zadachi
Β© SQL Arena, sql.coderang.dev