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
Writing SQL for Membership and Claims
00:00
5 left

Writing SQL for Membership and Claims

MediumSQL · PostgreSQL

Problem

Write a statement to get total membership for x service dates, and another to get count of claims and total members for x service dates when the dataset has duplicates.

For this exercise, use the distinct service dates present in the supplied data. Repeated records should be represented by the most recent ingestion for the same business record.

Output

  1. Return one row per service date with service_date, total_members, claim_count, and claim_members.
  2. Include only dates represented in either table, exclude duplicate earlier ingestions, and sort by service_date ascending.

Schema

membership
ColumnTypeDescription
ingestion_idPKINTEGERUnique ingestion row identifier; higher values are more recent.
member_idINTEGERCentene member identifier.
service_dateDATEDate for which membership coverage is reported.
plan_idVARCHAR(30)Health plan identifier.
coverage_statusVARCHAR(20)Coverage state for the member on the service date.
claims
ColumnTypeDescription
ingestion_idPKINTEGERUnique ingestion row identifier; higher values are more recent.
claim_idVARCHAR(30)Business identifier for a claim, repeated across duplicate ingestions.
member_idINTEGERCentene member associated with the claim.
service_dateDATEDate on which the claim service occurred.
claim_statusVARCHAR(20)Current status recorded for the claim ingestion.
Tablesmembershipclaims
Interviewer

Your question is Writing SQL for Membership and Claims. 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.