Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: Identify Trends Over Time

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

Your question is SQL: Identify Trends Over Time. 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

Huron Consulting Group needs a monthly view of engagement activity to identify periods with unusually high or low billable revenue. Write a PostgreSQL query using the engagement and work log data.

Requirements

  1. Include approved work logs from January through March 2025 that are linked to an engagement.
  2. Return one row per calendar month with total billable hours and billable revenue, treating missing hours as zero.
  3. Classify each month as Above average, Below average, or At average based on its revenue compared with the average monthly revenue for the selected period.
  4. Sort the output chronologically.

Schema

engagements
ColumnTypeDescription
engagement_idPKINTUnique engagement identifier
client_nameVARCHAR(120)Client or internal stakeholder name
service_lineVARCHAR(80)Huron service line supporting the engagement
start_dateDATEEngagement start date
statusVARCHAR(30)Current engagement status
work_logs
ColumnTypeDescription
log_idPKINTUnique work log identifier
engagement_idINTEngagement associated with the work log
work_dateDATEDate on which work was performed
billable_hoursNUMERIC(8,2)Number of billable hours recorded
hourly_rateNUMERIC(10,2)Billing rate applied to the work
log_statusVARCHAR(20)Approval state of the work log
Tablesengagementswork_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results