Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
Start free
SQL Joins and Date Aggregation
00:00
5 left

SQL Joins and Date Aggregation

MediumSQL · PostgreSQL

Problem

Agile Defense's mission support dashboard needs a daily summary of operational events across missions and monitored systems. Write a PostgreSQL query that joins mission events to their mission and system records, then aggregates the results by event date and mission.

Requirements

  1. Restrict results to events from April 1 through April 4, 2025, inclusive.
  2. Return the event date, mission code, mission name, total event count, completed event count, distinct systems involved, and total impact score.
  3. Use a LEFT JOIN for systems so events remain visible when a system record is unavailable. Treat a missing impact score as zero.
  4. Return only date and mission groups with more than one event, ordered by date and mission code.

Schema

missions
ColumnTypeDescription
mission_idPKINTEGERPrimary key for a mission
mission_codeVARCHAR(20)Short mission identifier
mission_nameVARCHAR(100)Mission display name
mission_events
ColumnTypeDescription
event_idPKINTEGERPrimary key for an event
mission_idINTEGERReferences missions.mission_id
system_idINTEGERReferences systems.system_id when available
event_recorded_atTIMESTAMPTimestamp when the event was recorded
statusVARCHAR(20)Current event status
impact_scoreINTEGERNumeric impact score
systems
ColumnTypeDescription
system_idPKINTEGERPrimary key for a monitored system
system_nameVARCHAR(100)System display name
system_categoryVARCHAR(50)System classification
Tablesmissionsmission_eventssystems
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.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.