Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Top Departments by Call Volume
00:00
5 left

Top Departments by Call Volume

MediumSQL · PostgreSQL

Problem

NJM Insurance Group wants to identify which departments handled the most calls during the previous calendar quarter. Write a PostgreSQL query that ranks departments by the number of calls received in that period.

Requirements

  1. Define the last quarter as the complete calendar quarter immediately before the anchored reference date of August 29, 2026.
  2. Count calls by department, excluding calls outside the last quarter and calls that do not reference a department.
  3. Return the top three departments, including department name and call volume.
  4. Break ties consistently by ordering department ID ascending after call volume descending.

Output

  1. Return one row per selected department with columns department_name and call_volume.
  2. Include only calls from April 1 through June 30, 2026. Calls with NULL or unmatched department IDs are excluded.
  3. Return the top three departments, ordered by call volume descending and department name ascending.
  4. Departments with no qualifying calls remain eligible with a count of zero, but are not expected in the top three.

Schema

departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)NJM department name
calls
ColumnTypeDescription
call_idPKINTUnique call identifier
department_idINTDepartment handling the call
started_atTIMESTAMPCall start timestamp
call_typeVARCHAR(50)Type of customer call
channelVARCHAR(30)Call intake channel
statusVARCHAR(30)Call status
Tablesdepartmentscalls
Interviewer

Your question is Top Departments by Call Volume. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.