Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Query Employees in Department
00:00
5 left

Query Employees in Department

EasySQL · PostgreSQL

Problem

Design employee and department tables (one-to-many, then many-to-many) and write a query listing all employees in a specific department.

Asked in the Round 2 stage.

Output

  1. Return one row per employee assigned to Ad Operations.
  2. Include employee_id, employee_name, and department_name.
  3. Order by employee_name, then employee_id.

Schema

departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Department name
department_descriptionVARCHAR(255)Optional department description
employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(150)Employee full name
employee_emailVARCHAR(255)Employee email address
primary_department_idINTOptional primary department for the one-to-many design
employee_departments
ColumnTypeDescription
employee_idPKINTEmployee participating in the department assignment
department_idPKINTDepartment participating in the employee assignment
assignment_typeVARCHAR(30)Type of department assignment
Tablesemployeesdepartmentsemployee_departments
Interviewer

Your question is Query Employees in Department. Start with the requirements and the three 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.