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 for Average Flights per Crew
00:00
5 left

SQL for Average Flights per Crew

MediumSQL · PostgreSQL

Problem

Write a SQL query to find the average number of flights per crew member over the last year at Atlas Air.

Use the provided crew member and flight assignment data. Include every crew member in the calculation, including members with no qualifying flights during the period.

Output

  1. Return one row with a column named average_flights_per_crew_member.
  2. Calculate the average from each crew member's distinct flight count during the rolling one-year period ending today.
  3. Round the result to two decimal places.

Schema

crew_members
ColumnTypeDescription
crew_member_idPKINTUnique identifier for a crew member
crew_member_nameVARCHAR(100)Crew member's full name
crew_roleVARCHAR(30)Operational role, such as pilot or flight engineer
base_codeVARCHAR(10)Primary Atlas Air operating base code
crew_flight_assignments
ColumnTypeDescription
assignment_idPKINTUnique identifier for an assignment record
crew_member_idINTAssigned crew member identifier
flight_idVARCHAR(20)Atlas Air flight identifier
flight_dateDATEScheduled or operated flight date
assignment_statusVARCHAR(20)Assignment state
Tablescrew_memberscrew_flight_assignments
Interviewer

Your question is SQL for Average Flights per Crew. 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.