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 Rolling 30-Day Claims Average
00:00
5 left

SQL Rolling 30-Day Claims Average

MediumSQL · PostgreSQL

Problem

Blue Cross and Blue Shield of Kansas needs a daily claims-volume trend for its active plan products. Write a PostgreSQL query that calculates the trailing 30-calendar-day average number of finalized claims for each active plan.

Requirements

  1. Count claims with status PAID or DENIED; exclude PENDED and VOID claims.
  2. Include calendar dates with zero claims so the average represents 30 calendar days rather than only days containing claims.
  3. Calculate the rolling average separately for each active plan using the current date and preceding 29 dates.
  4. Return results for January 31, 2025 through February 5, 2025, ordered by plan code and date. Round the average to four decimal places.

Schema

plan_products
ColumnTypeDescription
plan_codePKVARCHAR(20)Unique plan product identifier
plan_nameVARCHAR(100)Plan product display name
active_fromDATEProduct activation date
active_toDATEProduct deactivation date
claims
ColumnTypeDescription
claim_idPKINTUnique claim identifier
plan_codeVARCHAR(20)Associated plan product code
service_dateDATEDate of service
statusVARCHAR(20)Claim adjudication status
Tablesplan_productsclaims
Interviewer

Your question is SQL Rolling 30-Day Claims Average. 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.