Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Sign in or join

        SQL test for data analysts: what it checks and how to practice

        Data analyst SQL tests ask you to query a few business tables: filter and total, join without duplicating rows, handle NULLs, and rank rows with window functions. Practice free in our SQL skills test, which runs your queries on a real database in the browser and gives you your level.

        Checked 20 November 2026

        The SQL practice area: a query editor, the tables on the left and the rows your query returns, checked when you run it.
        The SQL practice area: a query editor, the tables on the left and the rows your query returns, checked when you run it.

        Four sample questions with answers

        The tables and values are fictional. These are original practice questions, not questions from any employer’s test.

        1. Revenue by month

        The table orders has order_id, order_date, status and amount. Show paid revenue for each month, oldest first.

        Answer:

        SELECT DATE_TRUNC('month', order_date) AS month, SUM(amount) AS revenue
        FROM orders
        WHERE status = 'paid'
        GROUP BY 1
        ORDER BY 1;

        The filter goes in WHERE, before grouping. A condition on the total, such as months over 10,000, would go in HAVING. Practice in GROUP BY.

        2. Customers who never ordered

        List customers with no orders.

        Answer: SELECT c.customer_id FROM customers c LEFT JOIN orders o ON o.customer_id = c.customer_id WHERE o.order_id IS NULL; An inner join would drop exactly the customers you are looking for. See LEFT JOIN.

        3. A total that came out too high

        Revenue looks inflated after joining orders to order_items. Why?

        Answer: Each order now appears once per item, so SUM(o.amount) counts an order’s amount several times. Total the items (SUM(i.quantity * i.unit_price)), or aggregate the items in a WITH step before joining. Check the row count whenever a join could add rows.

        4. The best seller in each category

        Return the top product by revenue in each category.

        Answer: Rank inside each category with ROW_NUMBER() OVER (PARTITION BY category ORDER BY revenue DESC) and keep rank 1. If two products can tie, use RANK() and say which one you chose. See window functions.

        How to practice before the test

        1. Take the free SQL skills test for your level.
        2. Work through the interview sets: basics, intermediate and advanced.
        3. Finish with the timed mock exam.

        The best SQL practice sites comparison shows where other sites fit next to this.

        ChatGPT teaches you. The Work Gym lets you practice.

        Where The Work Gym falls short

        • The practice database is DuckDB. Standard SQL works as written, but a test in MySQL, SQL Server or BigQuery may use different date and text functions, which the dialects unit covers.
        • We don't reproduce any employer's or test company's questions. The questions are original and test the same skills.
        • The skills test and the first unit are free without an account; the interview sets and the mock exam are part of a plan.

        Common questions

        What SQL do data analysts need for a test?

        SELECT with WHERE, GROUP BY and HAVING, inner and left joins, CASE WHEN, date functions, subqueries or WITH, and window functions such as ROW_NUMBER and LAG. The questions are about business tables: orders, customers, sessions, refunds.

        How are SQL assessments for analysts graded?

        Usually by the rows your query returns, compared with the expected result, sometimes on a hidden copy of the data. A query that returns the right total on the sample data can still fail on duplicates, NULLs or ties.

        Is there a free SQL test online?

        Yes. The Work Gym's SQL skills test is free and needs no account. It runs real queries, checks each one as you finish and ends with your level and the lesson to start at.

        How long should I practice before an analyst SQL test?

        Until joins, grouping and window functions feel routine on data you haven't seen. Take the skills test first: its result tells you which lessons to review instead of starting from zero.

        Sources

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        Your account can start a 5-day free trial: every course, unit, project and exam. Card needed; cancel any time and pay nothing.

        New accounts get 6 hours of full access: every course, unit, project and exam. The clock starts when you go past the free lessons.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.