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
Rank Clients by Premium
00:00
5 left

Rank Clients by Premium

MediumSQL · PostgreSQL

Problem

Arthur J. Gallagher & needs a regional view of client premium performance. Write a PostgreSQL query that ranks clients by their total active policy premium within each assigned region.

Requirements

  1. Aggregate active policy premiums for each client, treating missing or NULL premium values as zero.
  2. Include clients with no active policies, assigning them a total premium of zero.
  3. Use RANK() partitioned by region, with the highest total premium receiving rank 1. Preserve ties by assigning the same rank.
  4. Return the region, client, total active premium, and rank, ordered by region, rank, and client name.

Schema

regions
ColumnTypeDescription
region_idPKINTUnique region identifier
region_nameVARCHAR(80)Operating region name
clients
ColumnTypeDescription
client_idPKINTUnique client identifier
client_nameVARCHAR(120)Client legal or trading name
region_idINTAssigned region identifier
policies
ColumnTypeDescription
policy_idPKINTUnique policy identifier
client_idINTClient that owns the policy
policy_numberVARCHAR(30)Policy reference number
policy_statusVARCHAR(20)Policy lifecycle status
premium_amountNUMERIC(12,2)Policy premium amount
Tablesregionsclientspolicies
Interviewer

Your question is Rank Clients by Premium. Start with the requirements and the three 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.