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
Dynamic Table SQL Output
00:00
5 left

Dynamic Table SQL Output

MediumSQL · PostgreSQL

Problem

Explain how you would display data in a table where the column values are dynamic.

Use the provided flight and flight attribute data. Attribute names are not fixed in advance, so the result must preserve them dynamically rather than requiring a separate hardcoded column for each attribute.

Output

  1. One row per flight with columns flight_id, flight_number, status, and dynamic_columns
  2. dynamic_columns must contain each available attribute name and value for that flight
  3. Include flights without attributes with an empty object, exclude orphaned attribute records, and order by flight_id ascending

Schema

flights
ColumnTypeDescription
flight_idPKINTUnique flight identifier
flight_numberVARCHAR(20)Operational flight number
statusVARCHAR(20)Current flight status
flight_attributes
ColumnTypeDescription
flight_idPKINTFlight receiving the attribute
attribute_namePKVARCHAR(50)Dynamic attribute key
attribute_valueVARCHAR(255)Dynamic attribute value
Tablesflightsflight_attributes
Interviewer

Your question is Dynamic Table SQL Output. 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.