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
SQL Query for Employees in Troy
00:00
5 left

SQL Query for Employees in Troy

EasySQL · PostgreSQL

Problem

Dynatrace uses employee and office records to support workforce views in its internal engineering systems. Write a PostgreSQL query that returns all employees assigned to an office in Troy.

Requirements

  1. Join employees to offices using office_id.
  2. Return only employees whose office city is exactly Troy.
  3. Include the employee's name, job title, office city, country, and department name. Preserve Troy employees even when their department is not assigned.
  4. Order the results by last name, then first name, and employee ID for deterministic output.

Schema

employees
ColumnTypeDescription
employee_idPKINTEGERUnique employee identifier
first_nameVARCHAR(60)Employee first name
last_nameVARCHAR(60)Employee last name
job_titleVARCHAR(120)Employee job title
office_idINTEGERAssigned office identifier
department_idINTEGEROptional department identifier
offices
ColumnTypeDescription
office_idPKINTEGERUnique office identifier
cityVARCHAR(80)Office city
countryVARCHAR(80)Office country
departments
ColumnTypeDescription
department_idPKINTEGERUnique department identifier
department_nameVARCHAR(120)Department name
Tablesemployeesofficesdepartments
Interviewer

Your question is SQL Query for Employees in Troy. 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.