Skip to content

About

99 SQL practice problems with online checking: SELECT, JOIN, GROUP BY, subqueries, CTEs, window functions. Practice SQL and prepare for interviews.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

SQL Practice Problems with Online Checking

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.

Topics

Topic Problems
SELECT, WHERE, ORDER BY — filtering and sorting 20
Aggregate functions and GROUP BY 18
JOINs 18
Subqueries 9
CTEs (WITH clause) 8
Window functions 14
INSERT, UPDATE, DELETE — modifying data 6
CREATE and ALTER TABLE — table design 6

What a problem looks like

  • 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.

All problems

  1. Over-the-Counter Medications — easy
  2. Customers from Berlin — easy
  3. Platinum-Tier Members — easy
  4. Long-Haul Flights — easy
  5. Berlin Clubs — easy
  6. Premium Subscriptions — easy
  7. 5-Star Hotels — easy
  8. Rock Artists — easy
  9. Spacious Rooms — easy
  10. Festivals in 2024 — easy
  11. Endangered Species — easy
  12. Savanna Residents — easy
  13. Product Showcase: Rename the Columns — easy
  14. Products Under 1000 Rubles — easy
  15. Delivered Orders — easy
  16. Customer card: projection with aliases — easy
  17. Products from two warehouses — easy
  18. Catalog Without Archive — easy
  19. Warehouse shelf: SKU, weight and price under readable names — easy
  20. Drop Unrated Reviews, Replace Empty Comments — easy
  1. Monthly Sales Pulse — easy
  2. Listening Hours by Month — easy
  3. Store delivery scorecard — easy
  4. A Customer's First Digital Footprint — easy
  5. Duplicate Parcel Registrations — easy
  6. Purchase Frequency in an Audio App — easy
  7. Which Customers Need a Win-Back Campaign? — easy
  8. From KYC Submission to Approval — easy
  9. Most Read Books Lookup — easy
  10. Kotomarket monthly orders report — medium
  11. Top 3 categories by revenue — medium
  12. Average Salary of Employees by Departments for 2023 — medium
  13. Book Sales Split by Genre — medium
  14. Analysis of courier performance by delivered packages — medium
  15. Client Buying Behavior Study — medium
  16. Sales Split by Product Category — medium
  17. Box Office Revenue by Popular Genres — medium
  18. Most prolific authors with high ratings — medium
  1. Second-level shelves — easy
  2. One-to-one, one-to-many — easy
  3. Row fan-out after a JOIN — easy
  4. Comparable apartment pairs — easy
  5. Employees Shown with Their Departments — easy
  6. Popular vehicles with multiple bookings — easy
  7. Package delivery tracking by shipment codes — easy
  8. Top players with high average score — medium
  9. Analyzing Airline Route Profitability — medium
  10. High-Volume and Profitable Products — medium
  11. Most Active Authors by Published Articles Count — medium
  12. Overloaded Hospital Departments — medium
  13. Top hotel rooms by average rating and revenue — medium
  14. Top companies by average applicant review rating — medium
  15. Profitable room categories for the quarter — medium
  16. Doctors with the highest patient complexity — medium
  17. Analysis of insurance policy losses by region — medium
  18. Top farmers' yield by crops — medium
  1. Find the most expensive item — easy
  2. Pull orders from Russian customers only — easy
  3. Find orders bigger than average — easy
  4. Customers who already ordered something — easy
  5. Products that nobody bought — easy
  6. Show every customer's order count — easy
  7. Cheapest pick in every category — easy
  8. Parcel scans after the watermark — easy
  9. Documentary watchers — easy
  1. Top Bank Clients by Transaction Amount — hard
  2. Quarterly Performance of Sales Managers — hard
  3. Top Couriers by Deliveries with Urgency Priority — hard
  4. Employee Earnings Breakdown — hard
  5. Monthly Top Tracks in Playlists — hard
  6. Most-Played Artists Across Playlists — hard
  7. Student Performance Ranking by Department with Grade Dynamics — hard
  8. Revenue Month-on-Month Growth — hard
  1. Gaps between plays — easy
  2. Session-start flag in an online store — easy
  3. Neobank Operating Balance — easy
  4. Each Product's Share of Total Revenue via SUM() OVER () — medium
  5. Staff Salaries: How Far From the Average — medium
  6. Student Rating by Average Grade with Group Position — medium
  7. Crop Variety Yield Rankings by Plot — medium
  8. Genre Champions Among Library Readers — hard
  9. Payout Trends Across Insurance Policies — hard
  10. Gym Member Payment Momentum — hard
  11. Fleet Revenue Growth by Month — hard
  12. Monthly Box Office Peaks by Film — hard
  13. Rising Stars of the Travel Agency — hard
  14. Repeat Visit Intervals by Doctor — hard
  1. Discount on Action games — easy
  2. Seed a batch of test orders — easy
  3. Spring cleaning — drop everything unpinned — easy
  4. Save your first journal entry — easy
  5. Pin every January note for the new year — easy
  6. Add a test user — easy
  1. Drop the Departments Table — easy
  2. Add Email Column — easy
  3. Drop Salary Column — easy
  4. Rename Column name — easy
  5. Normalization: split a flat book catalog into authors + books (PK/FK) — medium
  6. Kotomarket: split an order into 3NF — medium

More problems

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

About

99 SQL practice problems with online checking: SELECT, JOIN, GROUP BY, subqueries, CTEs, window functions. Practice SQL and prepare for interviews.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors