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
Deep SQL and Recursion Interview
00:00
5 left

Deep SQL and Recursion Interview

HardSQL · PostgreSQL

Problem

Describe a time you were tested on deep SQL topics like complex joins and also on Python recursion and cloud computing concepts.

For the SQL portion, write a PostgreSQL query against the supplied tables to identify employees whose billable hours increased in a month and who worked on at least two distinct projects during that month.

Output

  1. One row per qualifying employee-month.
  2. Return employee_name, manager_name, department_name, month_start, billable_hours, prior_month_hours, change_percent, project_count, and department_rank.
  3. Include only qualifying increases with a positive prior-month value, and order by department_name, month_start, and employee_name.

Schema

departments
ColumnTypeDescription
department_idPKINTDepartment identifier
department_nameVARCHAR(100)Department name
employees
ColumnTypeDescription
employee_idPKINTEmployee identifier
employee_nameVARCHAR(100)Employee full name
department_idINTEmployee department
manager_idINTManager employee identifier
projects
ColumnTypeDescription
project_idPKINTProject identifier
project_nameVARCHAR(100)Project name
department_idINTOwning department
work_logs
ColumnTypeDescription
log_idPKINTWork log identifier
employee_idINTEmployee who recorded the work
project_idINTProject associated with the work
work_dateDATEDate of the work
hoursDECIMAL(8,2)Hours recorded
billableBOOLEANWhether the hours are billable
Tablesemployeesdepartmentsprojectswork_logs
Interviewer

Your question is Deep SQL and Recursion Interview. Start with the requirements and the four 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.