Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Query for Max Value

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Query for Max Value. Start with the requirements and the three tables on the right.

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.

Problem

Alegeus needs to review the largest approved reimbursement claims across benefit categories. Write a PostgreSQL query that returns every claim tied for the maximum eligible amount in its category.

Requirements

  1. Include only approved claims submitted during calendar year 2025.
  2. Include claims belonging to active members and exclude rows with a missing claim amount.
  3. Return all ties for the maximum claim amount in each category, along with the category, claim ID, member name, and maximum amount.
  4. Order the results by category ID and claim ID.

Representative Data

The data includes tied maximums, denied claims, inactive members, unmatched members, null amounts, zero amounts, and claims outside the requested year.

Schema

benefit_categories
ColumnTypeDescription
category_idPKINTBenefit category identifier
category_nameVARCHAR(40)Alegeus benefit category name
members
ColumnTypeDescription
member_idPKINTMember identifier
member_nameVARCHAR(100)Member display name
is_activeBOOLEANWhether the member is currently active
claims
ColumnTypeDescription
claim_idPKINTClaim identifier
category_idINTReferenced benefit category
member_idINTReferenced member
claim_statusVARCHAR(20)Claim processing status
submitted_atDATEDate the claim was submitted
claim_amountNUMERIC(10,2)Amount requested for reimbursement
Tablesbenefit_categoriesmembersclaims
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results