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 for Portfolio Exposure Summary
00:00
5 left

SQL for Portfolio Exposure Summary

MediumSQL · PostgreSQL

Problem

Barclays risk reporting needs a counterparty-level view of exposure across active portfolios. Write a PostgreSQL query that preserves counterparties with no current exposure.

Requirements

  1. Join counterparties to active portfolios and current open positions as of 2025-06-30.
  2. Return each counterparty's active portfolio count, open position count, and total exposure.
  3. Treat missing exposure as zero and preserve counterparties with no matching active portfolios or positions.
  4. Sort by total exposure descending, then counterparty name ascending.

Schema

counterparties
ColumnTypeDescription
counterparty_idPKINTUnique counterparty identifier
counterparty_nameVARCHAR(100)Counterparty legal or reporting name
regionVARCHAR(50)Primary operating region
portfolios
ColumnTypeDescription
portfolio_idPKINTUnique portfolio identifier
counterparty_idINTOwning counterparty identifier
portfolio_nameVARCHAR(100)Portfolio reporting name
portfolio_statusVARCHAR(20)Portfolio lifecycle status
positions
ColumnTypeDescription
position_idPKINTUnique position identifier
portfolio_idINTRelated portfolio identifier
position_dateDATEPosition valuation date
position_statusVARCHAR(20)Position lifecycle status
asset_classVARCHAR(40)Position asset class
exposure_amountNUMERIC(18,2)Signed exposure amount in reporting currency
Tablescounterpartiesportfoliospositions
Interviewer

Your question is SQL for Portfolio Exposure Summary. 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.