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
SQL Querying and OOP
00:00
5 left

SQL Querying and OOP

MediumSQL · PostgreSQL

Problem

How would you write SQL queries and relate them to an object-oriented design for a project-based requirement?

Use the projects, tasks, and employees tables. Return every project, including projects without tasks or an assigned owner, with the requested aggregate information.

Output

  1. One row per project with project_code, project_name, owner_name, total_tasks, completed_tasks, total_estimated_hours, completion_percentage, and project_status
  2. Include all projects, label missing owners as Unassigned, and sort by project_code ascending

Schema

projects
ColumnTypeDescription
project_idPKINTUnique project identifier
project_codeVARCHAR(20)Display code for the project
project_nameVARCHAR(100)Project name
owner_idINTOptional employee responsible for the project
tasks
ColumnTypeDescription
task_idPKINTUnique task identifier
project_idINTProject containing the task
task_nameVARCHAR(120)Task name
statusVARCHAR(30)Current task status
estimated_hoursDECIMAL(8,2)Estimated effort in hours
employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
full_nameVARCHAR(100)Employee display name
Tablesprojectstasksemployees
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

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.