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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
SQL Joins and Coin Selection
00:00
5 left

SQL Joins and Coin Selection

HardSQL · PostgreSQL

Problem

Coin selection puzzle, SQL Joins

Using coin_inventory and coin_types, write a query that returns every combination of three distinct physical coins whose denominations total exactly 100 cents. Each combination must be reported once, regardless of selection order.

Output

  1. One row per valid combination
  2. Columns: coin_id_1, coin_id_2, coin_id_3, value_1, value_2, value_3
  3. Include only combinations totaling 100 cents
  4. Order by the three coin IDs ascending

Schema

coin_types
ColumnTypeDescription
coin_type_idPKINTEGERIdentifier for a coin denomination type
coin_nameVARCHAR(40)Name of the denomination
denomination_centsINTEGERValue of the denomination in cents
coin_inventory
ColumnTypeDescription
coin_idPKINTEGERIdentifier for an individual physical coin
coin_type_idINTEGERReference to the coin denomination type
storage_binVARCHAR(20)Storage location for the physical coin
Tablescoin_inventorycoin_types
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

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.