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 Risk Limit Breach Query
00:00
5 left

SQL Risk Limit Breach Query

MediumSQL · PostgreSQL

Problem

Write a SQL query to extract daily portfolio values and identify assets that have exceeded their pre-defined risk limits.

Use the supplied portfolio valuation and risk limit data. Return all portfolio assets, including assets without a configured limit or with a missing valuation.

Output

  1. One row per portfolio, asset, and valuation date.
  2. Columns: asset_code, portfolio_id, valuation_date, daily_portfolio_value, risk_limit, excess_amount, and risk_status.
  3. risk_status must identify exceeded limits, values within limits, missing values, and missing limits. Order by asset_code, portfolio_id, and valuation_date.

Schema

portfolio_valuations
ColumnTypeDescription
valuation_idPKINTUnique valuation record identifier
portfolio_idVARCHAR(20)Portfolio identifier
asset_codeVARCHAR(20)Traded asset identifier
valuation_dateDATEDate of the valuation
market_valueNUMERIC(14,2)Asset market value for the valuation record
risk_limits
ColumnTypeDescription
limit_idPKINTUnique risk limit identifier
asset_codeVARCHAR(20)Asset governed by the limit
risk_limitNUMERIC(14,2)Pre-defined maximum permitted daily value
Tablesportfolio_valuationsrisk_limits
Interviewer

Your question is SQL Risk Limit Breach Query. 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.