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
Quarterly Executive KPI Report by Segment
00:00
5 left

Quarterly Executive KPI Report by Segment

MediumSQL · PostgreSQL

Problem

How would you approach designing a dashboard or report for executive stakeholders at Gartner to drive strategic decisions?

Using the supplied Gartner account and engagement tables, write a SQL query that produces a quarterly executive KPI report by client segment. Include only completed engagements from 2025 and calculate the requested metrics from the available data.

Output

  1. One row per client segment and quarter with completed engagements.
  2. Columns: segment, quarter_start, active_clients, completed_engagements, total_revenue, avg_satisfaction, revenue_growth_pct.
  3. Sort by segment ascending, then quarter_start ascending. The first quarter for each segment should have a NULL growth percentage.

Output details

  • Count active_clients as distinct account IDs with completed engagements in each segment and quarter.
  • Count completed_engagements as qualifying engagement rows, and calculate total_revenue as their revenue sum.
  • Round avg_satisfaction to two decimal places.
  • Calculate revenue_growth_pct against the previous reported quarter's total_revenue for the same segment.
  • Return revenue_growth_pct as NULL when previous revenue is NULL or zero, otherwise round it to two decimal places.
  • Sort NULL segment values last while retaining ascending segment and quarter ordering.

Schema

client_accounts
ColumnTypeDescription
account_idPKINTUnique Gartner client account identifier
account_nameVARCHAR(120)Client account name
segmentVARCHAR(60)Client market segment
advisory_engagements
ColumnTypeDescription
engagement_idPKINTUnique engagement identifier
account_idINTClient account associated with the engagement
engagement_dateDATEEngagement completion or scheduled date
statusVARCHAR(30)Engagement lifecycle status
revenueDECIMAL(12,2)Revenue attributed to the engagement
satisfaction_scoreDECIMAL(3,2)Client satisfaction score from 1.00 to 5.00
Tablesclient_accountsadvisory_engagements
Interviewer

Your question is Quarterly Executive KPI Report by Segment. Start with the requirements and the two 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.