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
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
Get started
Query High-Traffic Services for January 2026
00:00
5 left

Query High-Traffic Services for January 2026

MediumSQL · PostgreSQL

Problem

Describe your approach to optimizing database queries for high-traffic services.

Using the provided service and request data, write a PostgreSQL query that returns services with at least two requests during January 2026. Include only requests in that date range. The result should support evaluating traffic, latency, and server errors.

Output

  1. One row per qualifying service
  2. Columns: service_name, request_count, avg_duration_ms, error_rate_pct
  3. Sort by request count descending, then service name ascending

Output details

  • Treat January's bounds as inclusive at 2026-01-01 00:00:00 and exclusive at 2026-02-01 00:00:00.
  • Round avg_duration_ms to two decimal places.
  • Calculate error_rate_pct as the percentage of requests with status_code >= 500, rounded to two decimal places.

Schema

services
ColumnTypeDescription
service_idPKINTEGERUnique service identifier
service_nameVARCHAR(100)Display name of the service
api_requests
ColumnTypeDescription
request_idPKBIGINTUnique request identifier
service_idINTEGERReferenced service identifier
requested_atTIMESTAMPTimestamp when the request was received
endpointVARCHAR(150)Requested API endpoint
status_codeINTEGERHTTP response status code
duration_msINTEGERRequest duration in milliseconds
Tablesservicesapi_requests
Interviewer

Your question is Query High-Traffic Services for January 2026. 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.