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: 66

Reset filters
  • MediumPremium
    PostgreSQL · MySQL

    Average Time Between First and Second Posts

    Facebook analysts are looking at how regularly users publish posts. For each user with at least two posts, calculate the number of days between the dates of their first and second posts.

    Facebook (Meta)
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Bonds Ever Held in the Bank's Portfolio

    The investment team is reviewing the portfolio's history and wants to identify every bond that has ever been included in the bank's portfolio.

    Tochka
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Customers Who Purchased Products from Every Category

    Microsoft calls customers who have purchased at least one product from every category "Supercloud" customers. Find all of these customers and return their customer_id.

    Microsoft
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Distribution of Users by Number of Tweets

    Twitter is building a histogram of user activity for 2022. Group users by how many tweets they posted that year, using that number as tweet_bucket.

    Twitter (X)
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Maximum Account Balance by Region

    The regional analytics team wants the highest account balance in every region where clients hold accounts. Exclude regions where no clients have accounts.

    Sberbank
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Accounts of Companies with SBER in Their Names

    The sales team is looking for accounts belonging to companies whose names contain the substring SBER. For all such companies, return the account_id and account_type of their accounts.

    GlowByte
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Average Bug Fix Time by Severity

    The support team is evaluating how quickly bugs are fixed. For each severity, calculate the average number of days between reported_date and fixed_date.

    OpenAI
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Five Artists with the Most Top-10 Appearances

    Spotify wants to find the artists whose songs have appeared most often in the global chart's Top-10. Find the 5 artists with the most such appearances. Return artist_name and chart_appearances.

    Spotify
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Each User's Third Transaction

    Uber is preparing a report on user transactions. For each user with at least three transactions, find their third transaction when ordered by date from earliest to latest.

    Uber
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    City with the Most Users

    The growth team wants to identify the city with the most registered users. Find that city and return city and user_count.

    VK
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Moscow Clients with Total Credit Limits Above 20000

    The finance team wants to find clients with large combined credit limits across their cards. For clients in the Moscow region, add up the credit_limit values for all their cards.

    Alfa-Bank

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.