Free resource - No login required

    Free SQL Server Take-Home Assignment Template for Data Engineer Hiring

    Use this realistic SQL Server work-sample assignment to screen data engineering, analytics engineering, and SQL-heavy candidates before technical interviews.

    Includes SQL Server schema, sample data, candidate instructions, expected outputs, and scoring rubric.

    What's included

    This free SQL Server hiring assignment includes everything you need to run a structured technical screen.

    • Candidate instructions
    • SQL Server schema
    • Sample data (seed SQL)
    • 3 realistic SQL tasks
    • Expected output tables
    • Reviewer scoring rubric
    • Seniority calibration guidance

    Who this template is for

    This template is useful for teams hiring:

    • Data engineers
    • Analytics engineers
    • BI developers
    • Data analysts
    • Backend engineers working with SQL-heavy systems

    The assignment tests practical SQL reasoning, joins, aggregation, date handling, conditional logic, window functions, and ability to translate business requirements into correct SQL.

    SQL Server-specific skills tested

    This assignment tests practical SQL Server skills including DATEDIFF, DATEFROMPARTS, YEAR, MONTH, CAST, CASE expressions, aggregate functions, joins, grouping, rounding, common table expressions, and ROW_NUMBER window functions.

    Assignment scenario

    SaaS support operations analytics

    Candidates are given a small support-ticket dataset for a SaaS company. The dataset contains customers, support agents, and tickets. The goal is to write Microsoft SQL Server queries that help the support team understand SLA breaches, agent performance, and customer ticket burden.

    SQL Server schema and sample data

    Run this seed file to create the tables and load the sample dataset.

    This SQL Server version uses plan_name instead of plan so the column name stays clear in SQL Server contexts.

    sqlserver_seed.sql
    IF OBJECT_ID('dbo.tickets', 'U') IS NOT NULL DROP TABLE dbo.tickets;
    IF OBJECT_ID('dbo.agents', 'U') IS NOT NULL DROP TABLE dbo.agents;
    IF OBJECT_ID('dbo.customers', 'U') IS NOT NULL DROP TABLE dbo.customers;
    
    CREATE TABLE dbo.customers (
      customer_id INT PRIMARY KEY,
      company_name NVARCHAR(255) NOT NULL,
      plan_name NVARCHAR(50) NOT NULL
    );
    
    CREATE TABLE dbo.agents (
      agent_id INT PRIMARY KEY,
      agent_name NVARCHAR(255) NOT NULL,
      team NVARCHAR(100) NOT NULL
    );
    
    CREATE TABLE dbo.tickets (
      ticket_id INT PRIMARY KEY,
      customer_id INT NOT NULL,
      agent_id INT NOT NULL,
      priority NVARCHAR(20) NOT NULL,
      created_at DATETIME2 NOT NULL,
      first_response_at DATETIME2 NOT NULL,
      resolved_at DATETIME2 NOT NULL,
      reopened BIT NOT NULL DEFAULT 0,
      CONSTRAINT fk_tickets_customer
        FOREIGN KEY (customer_id) REFERENCES dbo.customers(customer_id),
      CONSTRAINT fk_tickets_agent
        FOREIGN KEY (agent_id) REFERENCES dbo.agents(agent_id),
      CONSTRAINT chk_priority
        CHECK (priority IN ('critical', 'high', 'normal'))
    );
    
    INSERT INTO dbo.customers (customer_id, company_name, plan_name) VALUES
      (1, 'Northwind Analytics', 'Startup'),
      (2, 'BluePeak Logistics', 'Growth'),
      (3, 'Cedar Bank', 'Enterprise'),
      (4, 'Luma Retail', 'Growth');
    
    INSERT INTO dbo.agents (agent_id, agent_name, team) VALUES
      (10, 'Ava', 'Platform'),
      (11, 'Mihkel', 'Data'),
      (12, 'Sara', 'Data');
    
    INSERT INTO dbo.tickets (
      ticket_id,
      customer_id,
      agent_id,
      priority,
      created_at,
      first_response_at,
      resolved_at,
      reopened
    ) VALUES
      (1001, 1, 10, 'high',     '2025-01-03T09:00:00', '2025-01-03T13:30:00', '2025-01-04T10:00:00', 0),
      (1002, 2, 11, 'normal',   '2025-01-05T08:00:00', '2025-01-06T10:00:00', '2025-01-07T09:00:00', 1),
      (1003, 3, 12, 'critical', '2025-01-08T14:00:00', '2025-01-08T19:00:00', '2025-01-09T14:00:00', 0),
      (1004, 4, 11, 'high',     '2025-01-10T10:00:00', '2025-01-10T17:00:00', '2025-01-11T12:00:00', 0),
      (1005, 3, 10, 'normal',   '2025-01-12T09:00:00', '2025-01-12T20:00:00', '2025-01-13T09:00:00', 0),
      (1006, 2, 12, 'critical', '2025-01-18T11:00:00', '2025-01-18T16:30:00', '2025-01-19T11:00:00', 1),
      (1007, 1, 10, 'normal',   '2025-02-02T09:00:00', '2025-02-03T08:00:00', '2025-02-04T09:00:00', 0),
      (1008, 2, 11, 'high',     '2025-02-04T12:00:00', '2025-02-04T22:00:00', '2025-02-05T10:00:00', 0),
      (1009, 4, 12, 'normal',   '2025-02-06T09:00:00', '2025-02-07T12:00:00', '2025-02-08T09:00:00', 0),
      (1010, 3, 10, 'critical', '2025-02-07T15:00:00', '2025-02-07T17:00:00', '2025-02-07T23:00:00', 0),
      (1011, 3, 11, 'high',     '2025-02-12T08:00:00', '2025-02-12T18:30:00', '2025-02-13T08:00:00', 1),
      (1012, 2, 12, 'normal',   '2025-02-16T09:00:00', '2025-02-16T20:00:00', '2025-02-17T09:00:00', 0);

    Candidate instructions

    You are given a small SaaS support-ticket database.

    Write Microsoft SQL Server queries to answer the tasks below. Use clear, readable SQL. You may use common table expressions, subqueries, aggregate functions, CASE expressions, and window functions.

    Return exactly the columns requested in each task. Follow ordering and tie-breaking rules exactly.

    Task 1

    SLA breach rate by month and plan

    Support leadership wants to understand whether customers on different plans are receiving timely first responses.

    SLA rules:

    • critical tickets: first response within 4 hours
    • high tickets: first response within 8 hours
    • normal tickets: first response within 24 hours

    Write a query that returns the SLA breach rate by month and customer plan.

    Expected columns:

    • month, plan, total_tickets, breached_tickets, breach_rate_pct

    Rules:

    • month should be the first day of the month as a date.
    • breach_rate_pct should be rounded to 1 decimal place.
    • Order by month ascending, then plan ascending.

    Solution query

    sqlserver_task_1_solution.sql
    SELECT
      CAST(DATEFROMPARTS(YEAR(t.created_at), MONTH(t.created_at), 1) AS date) AS [month],
      c.plan_name AS [plan],
      COUNT(*) AS total_tickets,
      SUM(
        CASE
          WHEN DATEDIFF(MINUTE, t.created_at, t.first_response_at) >
            CASE t.priority
              WHEN 'critical' THEN 4 * 60
              WHEN 'high' THEN 8 * 60
              WHEN 'normal' THEN 24 * 60
            END
          THEN 1
          ELSE 0
        END
      ) AS breached_tickets,
      CAST(
        ROUND(
          SUM(
            CASE
              WHEN DATEDIFF(MINUTE, t.created_at, t.first_response_at) >
                CASE t.priority
                  WHEN 'critical' THEN 4 * 60
                  WHEN 'high' THEN 8 * 60
                  WHEN 'normal' THEN 24 * 60
                END
              THEN 1.0
              ELSE 0.0
            END
          ) * 100.0 / COUNT(*),
          1
        ) AS decimal(5,1)
      ) AS breach_rate_pct
    FROM dbo.tickets t
    JOIN dbo.customers c
      ON t.customer_id = c.customer_id
    GROUP BY
      CAST(DATEFROMPARTS(YEAR(t.created_at), MONTH(t.created_at), 1) AS date),
      c.plan_name
    ORDER BY
      [month],
      [plan];

    Expected output

    monthplantotal_ticketsbreached_ticketsbreach_rate_pct
    2025-01-01Enterprise2150.0
    2025-01-01Growth3266.7
    2025-01-01Startup100.0
    2025-02-01Enterprise2150.0
    2025-02-01Growth3266.7
    2025-02-01Startup100.0
    Task 2

    Agent resolution performance

    The support manager wants to compare resolution speed for agents who resolved at least two tickets in January 2025.

    Write a query that returns each qualifying agent's number of resolved tickets and average resolution time.

    Expected columns:

    • agent_id, agent_name, resolved_tickets, avg_resolution_hours

    Rules:

    • Include only tickets resolved in January 2025.
    • Include only agents with at least 2 resolved tickets in that period.
    • avg_resolution_hours should be rounded to 1 decimal place.
    • Order by avg_resolution_hours ascending, then agent_id ascending.

    Solution query

    sqlserver_task_2_solution.sql
    SELECT
      a.agent_id,
      a.agent_name,
      COUNT(*) AS resolved_tickets,
      CAST(
        ROUND(
          AVG(CAST(DATEDIFF(MINUTE, t.created_at, t.resolved_at) AS decimal(10,2)) / 60.0),
          1
        ) AS decimal(5,1)
      ) AS avg_resolution_hours
    FROM dbo.tickets t
    JOIN dbo.agents a
      ON t.agent_id = a.agent_id
    WHERE t.resolved_at >= '2025-01-01T00:00:00'
      AND t.resolved_at < '2025-02-01T00:00:00'
    GROUP BY
      a.agent_id,
      a.agent_name
    HAVING COUNT(*) >= 2
    ORDER BY
      avg_resolution_hours,
      a.agent_id;

    Expected output

    agent_idagent_nameresolved_ticketsavg_resolution_hours
    12Sara224.0
    10Ava224.5
    11Mihkel237.5
    Task 3

    Highest customer burden by month

    Support leadership wants to know which customer generated the highest support burden in each month.

    Burden scoring:

    • critical ticket = 5 points
    • high ticket = 3 points
    • normal ticket = 1 point

    Write a query that returns the customer with the highest burden score for each month.

    Expected columns:

    • month, customer_id, company_name, burden_score

    Rules:

    • month should be the first day of the month as a date.
    • If two customers have the same burden score in a month, return the customer with the lower customer_id.
    • Order by month ascending.

    Solution query

    sqlserver_task_3_solution.sql
    WITH customer_monthly_burden AS (
      SELECT
        CAST(DATEFROMPARTS(YEAR(t.created_at), MONTH(t.created_at), 1) AS date) AS [month],
        c.customer_id,
        c.company_name,
        SUM(
          CASE t.priority
            WHEN 'critical' THEN 5
            WHEN 'high' THEN 3
            WHEN 'normal' THEN 1
          END
        ) AS burden_score
      FROM dbo.tickets t
      JOIN dbo.customers c
        ON t.customer_id = c.customer_id
      GROUP BY
        CAST(DATEFROMPARTS(YEAR(t.created_at), MONTH(t.created_at), 1) AS date),
        c.customer_id,
        c.company_name
    ),
    ranked AS (
      SELECT
        customer_monthly_burden.*,
        ROW_NUMBER() OVER (
          PARTITION BY [month]
          ORDER BY burden_score DESC, customer_id ASC
        ) AS rn
      FROM customer_monthly_burden
    )
    SELECT
      [month],
      customer_id,
      company_name,
      burden_score
    FROM ranked
    WHERE rn = 1
    ORDER BY [month];

    Expected output

    monthcustomer_idcompany_nameburden_score
    2025-01-012BluePeak Logistics6
    2025-02-013Cedar Bank8

    Reviewer scoring rubric

    Score the assignment out of 30 points, 10 points per task.

    DimensionPointsWhat to check
    Correctness5Returns correct rows and columns, handles joins and grouping correctly, follows ordering rules
    SQL quality2Readable structure, useful aliases, avoids unnecessary complexity, uses SQL Server features appropriately
    Edge cases2Handles SLA thresholds, month grouping, and tie-breaking correctly where required
    Communication1Query is easy for reviewers to understand; logic is clear enough to discuss in an interview

    Suggested interpretation

    25-30Strong practical SQL ability
    19-24Good working SQL ability, suitable for follow-up interview
    13-18Partial understanding, needs deeper review
    0-12Insufficient for SQL-heavy role

    How to use this manually

    You can use this template manually by copying the schema and sample data into a SQL Server database, sending the task descriptions to candidates, and reviewing their submitted SQL against the expected outputs and rubric.

    This resource is intentionally ungated. You can adapt the dataset, tasks, or scoring rubric to match your own hiring process.

    Validation commands

    sqlcmd -S "$SQLSERVER_HOST" -d "$SQLSERVER_DATABASE" -U "$SQLSERVER_USER" -P "$SQLSERVER_PASSWORD" -i sqlserver_seed.sql
    sqlcmd -S "$SQLSERVER_HOST" -d "$SQLSERVER_DATABASE" -U "$SQLSERVER_USER" -P "$SQLSERVER_PASSWORD" -i sqlserver_task_1_solution.sql
    sqlcmd -S "$SQLSERVER_HOST" -d "$SQLSERVER_DATABASE" -U "$SQLSERVER_USER" -P "$SQLSERVER_PASSWORD" -i sqlserver_task_2_solution.sql
    sqlcmd -S "$SQLSERVER_HOST" -d "$SQLSERVER_DATABASE" -U "$SQLSERVER_USER" -P "$SQLSERVER_PASSWORD" -i sqlserver_task_3_solution.sql

    Need another SQL dialect?

    This is the SQL Server version of the SQL take-home assignment template. You can also use:

    Want to create your own SQL assessment?

    How Datakaru helps

    Datakaru helps hiring teams create custom SQL and Python take-home assignments, send them to candidates, and review submissions with AI-assisted scoring.

    Use this template as a starting point, then build your own assessment in Datakaru based on your role, dataset, and hiring criteria.

    No credit card required - 14-day free trial

    Frequently asked questions

    What is a SQL Server take-home assignment?
    A SQL Server take-home assignment is a practical hiring task where candidates write Microsoft SQL Server queries against a sample database or realistic dataset. It helps hiring teams evaluate job-relevant SQL skills before a technical interview.
    What should a SQL Server hiring test evaluate?
    A good SQL Server hiring test should evaluate joins, filtering, aggregation, date handling, conditional logic, tie-breaking, and the candidate's ability to translate business questions into correct SQL.
    How long should a SQL take-home assignment take?
    For early screening, 30 to 60 minutes is usually enough. Longer assignments may create unnecessary candidate burden unless the role is senior or highly specialized.
    Can this template be used for data engineer hiring?
    Yes. This template is suitable for data engineer, analytics engineer, BI developer, and SQL-heavy analyst roles.
    Can I use this assignment in Datakaru?
    You can use this template manually, or use Datakaru to create your own custom SQL and Python take-home assignments for candidates.

    Ready to run better technical screens?

    Use this template as-is, or build your own custom SQL assignment in Datakaru.