Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 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
Build my plan
Call APIs and Aggregate Data
00:00
5 left

Call APIs and Aggregate Data

MediumSQL · PostgreSQL

Problem

Some questions about calling APIs, parsing the data, then using some sort of aggregation to display the data.

Using the parsed API request and record tables, produce a daily summary for successful requests only.

Output

  1. Return one row per endpoint and request date with endpoint, request_date, parsed_record_count, total_value, and average_value.
  2. Include successful requests with no parsed records, using zero for the count and total and NULL for the average.
  3. Sort by request_date, then endpoint.

Schema

api_requests
ColumnTypeDescription
request_idPKINTUnique identifier for an API request
endpointVARCHAR(100)API endpoint that was called
requested_atTIMESTAMPTimestamp when the request was made
http_statusINTHTTP response status code
api_records
ColumnTypeDescription
record_idPKINTUnique identifier for a parsed API record
request_idINTAPI request that produced the parsed record
record_typeVARCHAR(50)Type of parsed record
valueNUMERIC(10,2)Numeric value extracted from the API response
Tablesapi_requestsapi_records
Interviewer

Your question is Call APIs and Aggregate Data. 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.