DataBrighten

    Call center sample database for SQL Server

    1,000rows · 1 table · 6 questions with answers

    A ready-to-run SQL Server script with calls with queue, reason, wait and handle time, resolution and CSAT. Tested on SQL Server 2022 16.0.4325.4. Updated 19 November 2026.

    textnumberdateyes/no

    Call center database for SQL Server

    Each row is one inbound call in 2024: date and time, agent, queue, reason, seconds on hold, handle time, whether it was resolved and the 1-5 survey score (blank when the caller skipped the survey).

    This page has it as a SQL Server script: one table and 1,000 rows, with column types chosen for SQL Server, primary keys. The script drops the table if it exists, creates it and inserts the rows in one transaction, so you can run it again to reset the data. It is the same fictional data, seed 42, as on the call center dataset page, where it is also available as CSV and Excel.

    We loaded this exact file into SQL Server 2022 16.0.4325.4 and ran every question below on it; the answers shown are that output. The same questions, written for SQLite, PostgreSQL, MySQL, SQL Server and DuckDB, return the same results on all five.

    Load it

    sqlcmd

    sqlcmd -S localhost -Q "CREATE DATABASE practice"
    sqlcmd -S localhost -d practice -i call-center-sqlserver.sql

    SSMS or Azure Data Studio

    Create a database, open the .sql file in a new query window connected to it, and press Execute.

    Tables and columns

    call_center 1,000 rows

    ColumnSQL Server type
    call_idNVARCHAR(20)
    dateDATE
    timeNVARCHAR(10)
    agentNVARCHAR(30)
    queueNVARCHAR(20)
    reasonNVARCHAR(20)
    wait_secondsINT
    handle_secondsINT
    resolvedBIT
    satisfactionINT

    Practice questions

    answers from SQL Server 2022 16.0.4325.4

    How many calls did each queue take, and what share was resolved?

    SQL

    SELECT queue, COUNT(*) AS calls,
           ROUND(CAST(100 * SUM(CASE WHEN resolved = 1 THEN 1 ELSE 0 END) AS DECIMAL(18,6)) / NULLIF(COUNT(*), 0), 2) AS resolved_pct
    FROM call_center
    GROUP BY queue
    ORDER BY calls DESC, queue;

    Yes/no columns are BIT: 1 is true and 0 is false.

    Result

    queuecallsresolved_pct
    Technical35867.88
    Billing31986.21
    Returns16987.57
    Sales15485.71
    What are the average wait and handle times by queue, in seconds?

    SQL

    SELECT queue, ROUND(AVG(CAST(wait_seconds AS DECIMAL(18,4))), 2) AS avg_wait, ROUND(AVG(CAST(handle_seconds AS DECIMAL(18,4))), 2) AS avg_handle
    FROM call_center
    GROUP BY queue
    ORDER BY avg_wait DESC, queue;

    AVG of an INT column returns an INT in SQL Server, so the column is cast to DECIMAL first.

    Result

    queueavg_waitavg_handle
    Technical112.80525.53
    Returns103.25322.46
    Billing100.77337.89
    Sales100.70340.27
    How many calls arrive in each hour of the day? (time is stored as HH:MM text)

    SQL

    SELECT SUBSTRING(time, 1, 2) AS hour, COUNT(*) AS calls
    FROM call_center
    GROUP BY SUBSTRING(time, 1, 2)
    ORDER BY hour;

    SUBSTRING(text, start, length) cuts out part of a string.

    Result

    hourcalls
    0875
    0994
    1087
    1183
    1278
    1376
    1491
    1592
    1690
    1780
    1876
    1978
    Which 5 agents have the highest average satisfaction (at least 20 calls)?

    SQL

    SELECT TOP 5 agent, COUNT(*) AS calls, ROUND(AVG(CAST(satisfaction AS DECIMAL(18,4))), 2) AS avg_sat
    FROM call_center
    GROUP BY agent
    HAVING COUNT(*) >= 20
    ORDER BY avg_sat DESC, agent;

    SELECT TOP n ... ORDER BY returns the first n rows; SQL Server has no LIMIT.

    Result

    agentcallsavg_sat
    Linda Clark484.10
    Daniel Roberts564.06
    Charles Bell304.00
    Mary Baker424.00
    Aisha Miller473.94
    What are the top 5 call reasons?

    SQL

    SELECT TOP 5 reason, COUNT(*) AS calls
    FROM call_center
    GROUP BY reason
    ORDER BY calls DESC, reason;

    SELECT TOP n ... ORDER BY returns the first n rows; SQL Server has no LIMIT.

    Result

    reasoncalls
    Login problem97
    Refund request96
    Invoice question94
    Setup help91
    Bug report89
    How many calls were there per month?

    SQL

    SELECT CONVERT(char(7), date, 126) AS month, COUNT(*) AS calls
    FROM call_center
    GROUP BY CONVERT(char(7), date, 126)
    ORDER BY month;

    CONVERT(char(7), date, 126) keeps the first 7 characters of the ISO date (yyyy-mm). It is faster than FORMAT() and short enough to sort a window frame on.

    Result

    monthcalls
    2024-0173
    2024-0289
    2024-0368
    2024-0488
    2024-0581
    2024-0675
    2024-0788
    2024-0894
    2024-0985
    2024-1078
    2024-1186
    2024-1295

    SQL Server differences used here

    • AVG of an INT column returns an INT in SQL Server, so the column is cast to DECIMAL first.
    • Yes/no columns are BIT: 1 is true and 0 is false.
    • SUBSTRING(text, start, length) cuts out part of a string.
    • SELECT TOP n ... ORDER BY returns the first n rows; SQL Server has no LIMIT.
    • CONVERT(char(7), date, 126) keeps the first 7 characters of the ISO date (yyyy-mm). It is faster than FORMAT() and short enough to sort a window frame on.