SQL Interview Questions Practice

Prepare for SQL interviews by solving problems collected from real interviews at 77 companies, including Amazon, Microsoft, Meta, and others. Each problem identifies its company and covers practical SQL skills, from basic filtering to joins and aggregation. Your query runs in a real database and is automatically checked using hidden data. Problems: 172, free: 44.

Problems in this set: 172, free: 44

Start with a free problem

Interview problems

Problems found: 95

Reset filters
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    High-Spending Clients with Transaction Totals Above 9200

    The finance department identifies high-spending clients based on their total card transaction amounts. Find clients whose total transaction amount exceeds 9200. Return client_name and total_spent.

    Alfa-Bank
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Top Three Pilots by Passenger Count

    An airline plans to recognize its three leading pilots. For each pilot, add up the number of passengers across all their flights, then select the three pilots with the highest totals.

    T-Bank
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Bonds Never Held in the Portfolio

    The investment team wants to identify bonds that are listed in the database but have never been held in the bank's portfolio.

    Tochka
  • MediumPremium
    PostgreSQL · ClickHouse

    Transactions Converted to Rubles

    MegaFon's financial reporting requires all foreign-currency transactions to be converted to rubles.

    Megafon
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Two Most Active Customers

    An e-commerce platform identifies its most active customers by the number of distinct products they have purchased.

    Microsoft
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Rolling Average of Tweet Counts

    Twitter calculates a 3-day rolling average of user activity.

    Twitter (X)
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Clients Who Have Not Opened Any Accounts

    The onboarding team is looking for clients who have not opened any accounts. Return the name of each client who has no records in the accounts table.

    Sberbank
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Works That Have Never Been Checked Out

    A librarian is reviewing the catalog for works nobody has borrowed. Find works that have never been checked out, meaning they have no records in checkouts. Return all columns for those works.

    Cian
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Drivers with More Than One Ride

    A ride-hailing service wants to find drivers with multiple ride bookings. Find drivers who have more than one ride, counting all rides, including canceled ones. Return name and ride_count.

    Yandex
  • MediumPremium
    PostgreSQL · ClickHouse

    Monthly Employee Salaries with Changing Hourly Rates

    Avito's finance team is calculating monthly payroll for contact center employees. Hourly rates can change within a month, so use the rate in effect on each workday.

    Avito
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Account Count by Company

    The finance department is preparing a summary of company contracts. For each company, count its accounts (account_count). Include companies with no accounts and report 0 for them.

    GlowByte
  • MediumPremium
    PostgreSQL · ClickHouse

    SVOD and AVOD Views Over the Last 30 Days

    At ivi, content can be subscription-based (SVOD), ad-supported (AVOD), or pay-per-view (TVOD). The product analytics team needs daily view counts over the last 30 days for two target platforms.

    IVI

What you will practice

  • Translate business questions into SQL queries
  • Define what each row of the answer should represent
  • Combine filtering, joins, and aggregation in one query
  • Check duplicates, missing values, and boundary cases
  • Explain why a query answers the original question

Common mistakes

  1. 1. Counting events instead of users

    Interview problems often ask for counts of users, orders, or actions. Those are different units. When one user generates several events, counting rows can inflate the answer. Before writing SQL, define what one counted item represents and whether repeated records should contribute.

  2. 2. Ignoring ties in ranking problems

    Several users, products, or categories may share the same score. Sorting with LIMIT does not always produce the ranking logic the problem expects. Check whether the requested result is a fixed number of rows or includes all records tied at a particular rank.

  3. 3. Misreading date range boundaries

    Phrases such as during a day, last month, and after a date describe different intervals. A query may work on ordinary records but fail at the boundaries. Check whether start and end values are inclusive and whether the column contains dates or timestamps.

  4. 4. Letting joins inflate business metrics

    Joining tables can duplicate an order, payment, or user before aggregation. The final numbers may look reasonable even when they are incorrect. Identify the level of detail in each table and verify that the JOIN does not multiply the entity you intend to count or sum.

Theory and courses

Frequently asked questions

Can I practice SQL interview problems for free?

Yes. Total problems in this collection: 172, free: 44. After signing in, you can solve up to 3 new problems per day on the free plan. Premium problems remain visible in the list but require a subscription to solve.

Are solutions to the interview questions available?

Reference SQL solutions are not published. You write and submit your own query, which runs in a real database. The trainer automatically compares its output with an expected result using hidden data. Problems include hints and an AI mentor to help with your approach.

What does the company name on a problem mean?

Every problem in this collection is associated with a company where it appeared in an interview. The collection covers 77 companies. The name provides context for the question, but solving it still comes down to understanding the tables, the business requirement, and the expected output.

Is knowing JOIN and GROUP BY enough for SQL interviews?

Not entirely. This collection includes different kinds of SQL problems, including selections, joins, aggregations, and more involved data analysis. Rather than memorizing individual query patterns, practice identifying which operations a question requires and checking whether the result is logically correct.

How should I check an interview solution before submitting?

First define what one output row represents: a user, order, product, or event. Then review filters, joins, duplicates, missing values, and date boundaries. For ranking problems, consider ties. These checks can reveal logical mistakes even when the SQL executes without syntax errors.