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
SQL Join and Monthly Summary
00:00
5 left

SQL Join and Monthly Summary

MediumSQL · PostgreSQL

Problem

Write a SQL query to join multiple tables and calculate a monthly summary of analyst-relevant metrics.

Use the provided analyst, activity, and target tables. Include activity from January through March 2025 and preserve months that have activity but no matching target.

Output

  1. One row per analyst and activity month
  2. Columns: analyst_name, month_start, activity_count, completed_count, total_metric_value, average_metric_value, target_value, attainment_percentage
  3. Include all activity records in the period, including records with null metric values
  4. Order by analyst_id, then month_start

Schema

analysts
ColumnTypeDescription
analyst_idPKINTUnique analyst identifier
analyst_nameVARCHAR(100)Analyst display name
regionVARCHAR(50)Analyst reporting region
active_flagBOOLEANWhether the analyst is currently active
analyst_activity
ColumnTypeDescription
activity_idPKINTUnique activity identifier
analyst_idINTReferences analysts.analyst_id
activity_dateDATEDate when the activity occurred
activity_typeVARCHAR(50)Type of analyst activity
statusVARCHAR(30)Current activity status
metric_valueDECIMAL(12,2)Numeric value associated with the activity
monthly_targets
ColumnTypeDescription
target_idPKINTUnique monthly target identifier
analyst_idINTReferences analysts.analyst_id
target_monthDATEFirst day of the target month
target_valueDECIMAL(12,2)Target metric value for the month
Tablesanalystsanalyst_activitymonthly_targets
Interviewer

Your question is SQL Join and Monthly Summary. Start with the requirements and the three 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.