Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Join with Aggregation

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Join with Aggregation. Start with the requirements and the two tables on the right.

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.

Problem

The Alten Delivery Centre Spain needs a quarterly view of approved, billable work logged against active delivery projects. Write a PostgreSQL query that joins project and work-log data and returns only projects meeting the minimum effort threshold.

Requirements

  1. Consider active projects in the Alten Delivery Centre Spain portfolio.
  2. Include only approved, billable work logs recorded from 2025-01-01 through 2025-03-31.
  3. Return each qualifying project's ID, name, delivery centre, manager, total approved billable hours, and log count.
  4. Keep projects with no qualifying logs during the join, but return only projects with at least 20 approved billable hours. Classify totals of 40 hours or more as High, otherwise as Standard.

Schema

projects
ColumnTypeDescription
project_idPKINTEGERUnique project identifier
project_nameVARCHAR(100)Project name
delivery_centreVARCHAR(80)Alten delivery centre responsible for the project
manager_nameVARCHAR(100)Assigned project manager
project_statusVARCHAR(20)Current project lifecycle status
work_logs
ColumnTypeDescription
log_idPKINTEGERUnique work-log identifier
project_idINTEGERProject associated with the work log
logged_onDATEDate on which work was recorded
hoursNUMERIC(8,2)Recorded work hours
log_statusVARCHAR(20)Approval status of the work log
is_billableBOOLEANIndicates whether the work is billable
Tablesprojectswork_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results