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
Deduplicated Investment Value Query
00:00
5 left

Deduplicated Investment Value Query

MediumSQL · PostgreSQL

Problem

Calculate the total investment value in 2012 using two decimal places, ensuring that the same holder is not counted multiple times, utilizing three inner joins.

Use the provided holder, account, investment, and investment value records. Include qualifying 2012 records only, and prevent duplicate valuation records from inflating the result.

Output

  1. Return one row with total_investment_value and qualifying_holders.
  2. Report the combined value to two decimal places and the number of unique holders represented.
  3. Return exactly one result row.

Schema

holders
ColumnTypeDescription
holder_idPKINTUnique holder identifier
holder_nameVARCHAR(100)Holder name
accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
holder_idINTHolder who owns the account
account_labelVARCHAR(100)Optional account label
investments
ColumnTypeDescription
investment_idPKINTUnique investment identifier
account_idINTAccount associated with the investment
investment_typeVARCHAR(60)Investment classification
investment_values
ColumnTypeDescription
value_idPKINTUnique valuation record identifier
investment_idINTInvestment being valued
valuation_dateDATEDate of the valuation
investment_valueNUMERIC(14,2)Investment value on the valuation date
Tablesholdersaccountsinvestmentsinvestment_values
Interviewer

Your question is Deduplicated Investment Value Query. Start with the requirements and the four 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.